Converts a CSV file to a two-dimension array.
ArrayFileGetCsv( filename, flags [, delimiter [, extra-rows [, extra-columns]]])
(s) filename: path and file name of the file.
(i) flags: see below.
(s) delimiter: [optional] specifies the character used to separate values on each line of the file. It can be any single printable character, numbered from 32 to 126 (decimal), except a space(32) or double quotation mark(34). If omitted, a comma will be used as the delimiter.
(i) extra-rows: [optional] specifies the number of additional elements to add to the end of dimension 1 of the array. If omitted, it will be 0.
(i) extra-columns: [optional] specifies the number of additional elements to add to the end of dimension 2 of the array. If omitted, it will be 0.
(a) array a two dimensional array.
Note: A Comma Separated Values (CSV) file is a file format used as a portable representation of a database. Each line is one entry or record and the fields in a record are separated by commas. Commas may be followed by arbitrary space and/or tab characters which are ignored. If field includes a comma, the whole field must be surrounded with double quotes.
Line break handling within CSV files
WinBatch will not handle a line break within a field. WinBatch considers a line feed to be the end of a line. In this case, the layout of the CSV file will be disrupted or broken.
Flags can be set to 0, or can specify one or more of the following values combined with the bitwise OR ('|') operator:
Value |
Meaning |
1 |
Treat leading and trailing whitespace as significant |
This function creates a two-dimension array and stores each line of the specified CSV file as rows and columns in the array. The first item on line 1 of the file is stored as array[0, 0], the second item on line 1 of the file is stored as array[0, 1], the first item on line 2 of the file is stored as array[1, 0], and so on.
By default, the maximum supported file line length is 4096. This can be increased using IntControl 65.
The file may not contain any NULL characters.
filename = "c:\temp\test.csv" array = ArrayFileGetCSV(filename, 0, ",", 0, 0) rowcount = ArrInfo(array,1) colcount = ArrInfo(array,2) Message(StrCat("Number of Rows in the file ",rowcount), StrCat("Number of Columns in the file ",colcount))
IntControl 39, Arrays, ArrayFileGet, ArrayFileGetCsv, ArrayFilePut, ArrayFilePutCsv, ArrayFromStr, ArrayInsert, ArrayItemize, Arrayize, ArrayLocate, ArrayRedim, ArrayRemove, ArrayReverse, ArraySort, ArraySwapElements, ArrayToStr, ArrDimension, ArrInfo, ArrInitalize, Drop