|
Write to a CSV file.
syntax
SaveCsvFile(
fileName,
data
[,bHeader = FALSE]
[,headerData]
[,bDoubleQuatation = TRUE]
[,bOverwrite = TRUE]
[,bLastReturn = TRUE]
[,separator = ","]
[,dateTimeFormat = ""]
[,bNullIsEmptyString = FALSE]
)
Parameters
fileName
|
|
Type:
|
character
|
|
File name. If [ansi] is specified, it will be saved in ANSI format. If omitted, it will be saved in utf8 (with BOM).
|
data
|
|
Type:
|
Character Array
|
|
The variable in which the contents of the CSV file are stored. Usually, it is passed in the form of a two-dimensional array (data[ column, row]). If it is a one-dimensional array (data[ column]), there will be only one row.
|
bHeader
|
|
Type:
|
Boolean
|
|
When TRUE, the first line of the CSV file will be the title line.
|
headerData
|
|
Type:
|
One-dimensional character array
|
|
When bHeader is TRUE, the first line of the CSV file is regarded as the title line, and the contents of that title are set as a one-dimensional array (headerData [column]).
|
bDoubleQuatation
|
|
Type:
|
Boolean
|
|
When TRUE is specified, be sure to enclose each piece of data in double quotes.
When FALSE, enclose data in double quotes only when necessary.
This is necessary when the data contains a comma ",".
|
bOverwrite
|
|
Type:
|
Boolean
|
|
If TRUE, overwrite the file.
If FALSE, append to the file.
|
bLastReturn
|
|
Type:
|
Boolean
|
|
If TRUE, put a return character after the last record.
If FALSE, no return character will be placed after the last record.
|
separator
|
|
Type:
|
character
|
|
Delimiter. (Cannot be more than one character.)
|
dateTimeFormat
|
|
Type:
|
character
|
|
Date and time format. If nothing is specified, it is the same as %Y/%m/%d %H:%M:%S.
|
bNullIsEmptyString
|
|
Type:
|
Boolean
|
|
If the value is TRUE and N/A, it will be set to an empty string. If the value is FALSE, it will be set to "N/A".
|
Return Value
|
|
Type:
|
Boolean
|
|
FALSE - Failure. TRUE - Success.
|
Explanation
Writes to a CSV file. This function cannot be used unless you log in to the server.
If you specify [ansi] at the beginning of the file name specified in the fileName argument, it will be saved in ANSI format. If you omit it, it will be saved in utf8 (with BOM).
Example) [ansi]c:\work\log.txt
|
Example
|
var a[3,10]; // 3 columns and 10 rows of data
…
::SaveCsvFile("c:\abc.txt", a); // With double quotes
::SaveCsvFile("c:\abc.txt", a, F, 0, F); // Without double quotes
::SaveCsvFile("c:\abc.txt", a, F, 0, T, T, T, ::Chr(0x09)); // Specify tab as delimiter
|
|
Supported
reference
LoadTextFile
SaveTextFile
LoadCsvFile
SaveCsvFile
SavePrintText
GetTempFolder
GetTempFile
GetCurrentFolder
GetModuleFolder
GetFileSize
GetFileLastWriteTime
GetLogicalDrives
GetDriveType
EncryptFile
DecryptFile
SetClipboardData
GetClipboardData
|