MapFilePutCsv

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

Syntax:

MapFilePutCsv( filename, map[, delimtier [,write-undef[, flags]]] )

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.

(i) write-undef: [optional] set to @True(1) to write keys with undefined values to the file. The defaults is for keys with undefined values to not be written to file.

(i) flags: [optional] see below. Defaults to 0.

Returns:

(i)  number of bytes written to the file.

 

"flags" can be set to 0, or can specify one or more of the following values combined with the bitwise OR ('|') operator:

Value

Meaning

2

Do not add double quotes to each field of the  CSV file. This should only be used when you are sure the 'delimiter' is not present in the data.

 

By default, each line in the file will be terminated with a CR/LF. This can be changed using IntControl 53.

 

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.

See the MapCreate topic for a detailed description of WIL maps and how they differ from regular WIL arrays.

Example :
outputfile = "c:\temp\output.csv"
pairs = 'Apples,0':@tab:'Oranges,0':@tab:'Pears,0'
map = MapCreate(pairs)
MapFilePutCSV(outputfile, map, ",",@true,0)
Message('Done', 'WIL map written to a file.')
See Also:

MapCreate, MapFileGetCsv, MapKeyExist, MapKeyRemove, MapKeysGet, MapKeyFind