MapFileGetCsv

Converts a file to a WIL map (associative array.)

Syntax:

MapFileGetCsv(filename[, delimiter])

Parameters:

(s) filename: path and file name of the CSV file.

(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.

Returns:

(m)  a new WIL map.

 

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.

The MapFileGetCsv function creates a WIL map using the first two columns of the CSV file.  The first column of each record becomes a map key and the second column of each record because the key's value.  Any additional columns in each record are ignored. See the MapCreate topic for a detailed description of WIL maps and how they differ from regular WIL arrays.

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.

Example :
filename = "c:\temp\test.csv"
map = MapFileGetCSV(filename)
paircount = ArrInfo(map,1)
Message('Map Pairs', 'Number of key-value pairs in the file ':paircount )
See Also:

MapCreate, MapFilePutCsv, MapKeyExist, MapKeyRemove, MapKeysGet, MapKeyFind