CSV Source
The xls
source can also create a requisition from a UTF-8 encoded, comma-separated variable (CSV) file if the given file name has the .csv
suffix.
In this case the first line of the CSV file should contain a comma-separated list of headers in the same way the spreadsheet should be configured in a normal XLS source. Alternatively, you can set a property containing a comma-separated set of headers to use as the first line of the CSV file. This lets PRIS read CSV files that do not have a header.
Parameter | Required | Description |
---|---|---|
|
* |
Set |
|
* |
Path of the CSV file to read relative to the |
|
If this property is not present, the first line of the CSV file is used as the column headers in the same way as in the XLS data source. If this property is set, the value of this field should be a comma-separated set of headers to use instead of using the first line of the CSV file. |
The structure of the CSV file should follow the same rules and use the same headers as in the XLS data source.
However, any columns that would contain comma-separated values in a spreadsheet must have the contents delineated using a semicolon ';' character rather than commas. In the following example, the svc_Forced services ICMP;SNMP are separated using a semicolon.
Node_Label,IP_Management,MgmtType_,svc_Forced,cat_Environment
bbone-gw2,10.0.23.2,P,ICMP;SNMP,Backbone
Example configuration for the requisition myinventory
from a CSV file myinventory.csv
:
### File: myRouter/requisition.properties
# This example imports devices from a spreadsheet
# named "myRouter" from the myInventory.xls file
# Path to the XLS fils is relative to
# requisitions.properties
source = xls
source.file = ./myinventory.csv
### default no-operation mapper
mapper = echo
Example configuration for the requisition myinventory-noheaders
from a CSV file myinventory-noheaders.csv
:
This example has a source.org.opennms.pris.spreadsheet.fields
property set:
### File: myRouter/requisition.properties
# This example imports devices from a spreadsheet
# named "myRouter" from the myInventory.xls file
# Path to the XLS fils is relative to
# requisitions.properties
source = xls
source.file = ./myinventory-noheaders.csv
source.org.opennms.pris.spreadsheet.fields=Node_Label,IP_Management,MgmtType_,svc_Forced,cat_Environment
### default no-operation mapper
mapper = echo