Connector Framework Server 25.1
Connector Framework Server Help

# write_csv

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:

- The `DREREFERENCE` and `DRECONTENT` fields are always included. You do not need to specify these fields.
- To specify a field, type the field name. For example: For example: `"MyField"`.
- To specify a sub-field, type the field name, followed by a forward slash, followed by the name of the sub-field. For example: `"MyField/SubField"`.
- To specify a field attribute, type the field name, followed by a forward slash, followed by the name of the attribute. Prefix the attribute name with the '`@`' character. For example: `"MyField/@attribute"`.
- If you specify a field that has multiple values, all of the values are included in the output.

## Syntax

    write_csv( doc, CsvWriterFilename , CsvWriterFieldNames
           [, CsvWriterArchiveDirectory, CsvWriterMaxSizeKBs] )

## Arguments

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.

## Returns

Boolean. Returns `true` if the CSV file was created successfully, and `false` otherwise.

## Example

    function handler(document)
       write_csv(document, "MyTask.csv",
           {"MyField", "MyField/Subfield","MyField/@attribute" } ,
           "CSVarchive", 1024 )
       return true
    end

Copyright 2024 Open Text
Version 25.1 | Last updated January 2025

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: Knowledge Discovery Connector Framework Server 25.1

Topic Title: write_csv