This tool can be used to import a series of points contained within a comma-separated values (*.csv) file into a vector shapefile of a POINT ShapeType. The input files must be ASCII text files with a .csv extensions. The user can optionally specify an arbitrary number of column definitions of x-coordinate, y-coordinate, numerical attribute, or string attribute. If column defintions are not specified, the tool will automatically detect the column type, and importantly, it will assume that the first column containing decimal data cooresponds to the x-coordinate and that the second such column is the y-coordinate. If automatic column detection is used, integer x- and y-coordinates should be avoided. When automatic column detection is used, all non-coordinate columns will be automatically imported as attributes, appended to the the output shapefile's attribute table. The tool will also automatically detect whether the first line of the file is a header line and should therefore be excluded from data import.
The following is an example of a Python script using this tool:
wd = pluginHost.getWorkingDirectory()
# You may have multiple input files but they must
# be separated by semicolons in the string.
inputFiles = wd + "input1.csv" + ";" + wd + "input2.csv" + ";" + wd + "input3.csv"
args = [inputFiles]
pluginHost.runPlugin("ImportCSV", args, False)
This is a Groovy script also using this tool:
def wd = pluginHost.getWorkingDirectory()
// You may have multiple input files but they must
// be separated by semicolons in the string.
def inputFiles = wd + "input1.csv" + ";" + wd + "input2.csv" + ";" + wd + "input3.csv"
def firstColumnDef = "x"
def secondColumnDef = "y"
def thirdColumnDef = "numerical"
def fourthColumnDef = "string"
String[] args = [inputFiles, firstColumnDef, secondColumnDef, thirdColumnDef, fourthColumnDef]
pluginHost.runPlugin("ImportCSV", args, false)