The write_csv function writes a document’s metadata and content to a comma-separated values (CSV) file on disk. The function writes a blank line, followed by a line of field names, followed by a line that contains the field values.
The CsvWriterFieldNames argument specifies the document fields that you want to write to the CSV file:
DREREFERENCE and DRECONTENT fields are always included. You do not need to specify these fields."MyField"."MyField/SubField".@' character. For example: "MyField/@attribute".write_csv( doc, CsvWriterFilename , CsvWriterFieldNames
[, CsvWriterArchiveDirectory, CsvWriterMaxSizeKBs] )
| Argument | Description |
|---|---|
doc
|
(LuaDocument) The document to write to the CSV file. |
CsvWriterFilename
|
(string) The filename of the output CSV file. |
CsvWriterFieldNames
|
(table of strings) The document fields that you want to write to the CSV file. The function always writes the document’s reference (DREREFERENCE) and content (DRECONTENT), so you do not need to specify these fields. |
CsvWriterArchiveDirectory
|
(string) The path to the directory where CSV files are archived when they exceed the size specified by CsvWriterMaxSizeKBs. |
CsvWriterMaxSizeKBs
|
(integer) The maximum size of CSV files, in kilobytes. When a file exceeds this size it is moved to the archive directory specified by CsvWriterArchiveDirectory. A timestamp is added to the file name so that it has a unique name. |
Boolean. Returns true if the CSV file was created successfully, and false otherwise.
function handler(document)
write_csv(document, "MyTask.csv",
{"MyField", "MyField/Subfield","MyField/@attribute" } ,
"CSVarchive", 1024 )
return true
end
|
|