GoFiler Legato Script Reference
Legato v 1.5d Application v 5.25a
|
Table of Contents | < < Previous | Next >> |
Chapter Eight — Data Functions (continued)
Comma Separated Values (CSV, also commonly known as comma delimited lists) provides a de facto standard manner to exchange simple data tables in plain-text form. Plain-text means that the file is a sequence of characters with no binary data or codes have to be interpreted. Instead each line of text is a table row or a record.
The format is meant to convey rows and columns in the form of lines and fields. It is named, “comma-separated” because each field is separated by comma. If a field’s text contains a comma, the data within the field is enclosed as a quoted string. For example, fields:
1 A String text with a comma, 0.00
Would be represented as:
1,A String,"text with a comma,",0.00
or...
"1","A String","text with a comma,","0.00"
Text is not necessarily encoded except for enclosure within quotes for fields with a comma or if the text has a double quote. Double quotes must be escaped with an additional quote, for example:
Mike said, "This is my string"
This is represented as:
"Mike said, ""This is my string"""
A CSV file consists of any number of records separated by line breaks. However, line breaks can be inside a quoted field. Each record consists of fields separated by comma. Usually, all records have an identical number and sequence of fields. There are no standard provisions for field names, data types or row characteristics. It is common for the first row to be the field names for the table.
There are variations in CSV as well as compatibility issues. For example, Excel allows for the embedding of return characters (0x0D) within a quoted field which counts as return code in the field data, not a new record.
Legato provides a variety of functions to work with reading and writing fields, records or complete files. CSV data is processed as strings, arrays and tables.
Some CSV functions require a CSV Object. The object allows for the control of input and output of CSV data. The object is created using the CSVCreate function. When a function or script has completed using a CSV Object, it can close the handle or let it be automatically closed on function exit if locally declared.
A CSV Object can be used simultaneously employed for input and output.
There are a number of functions that do not require an object since the operations performed are transient. For example, the CSVReadTable function reads an entire file into a two-dimensional array (table) and therefore an object is not required.
An addition to the CSV Object, the Data Sheet Object also will process CSV information.
Control:
CSVCreate — Creates a CSV Object for reading and writing comma-separated data.
CSVReset — Resets the read and write buffers within a CSV Object.
CloseHandle — Closes an object handle and releases any associated resources.
Reading:
CSVGetFieldCount — Returns a count of CSV fields within a record either as part of a CSV Object or independent string.
CSVGetFields — Returns all the CSV fields from a CSV Object for a simple CSV string.
CSVGetNumericField — Gets and translates a field from a CSV Object into a numeric value.
CSVGetStringField — Gets and translates a field from a CSV Object into a string value.
CSVIsLastField — Tests for last field in input buffer of a CSV Object.
CSVIsLastRecord — Tests for last record in input buffer of a CSV Object.
CSVReadTable — Reads an entire CSV table into a 2 dimensional array from a file as a Basic File Object or a filename.
CSVSetRecord — Sets a string (record) into the CSV Objects parse buffer.
Writing
CSVAppendField — Appends a value to a CSV Object write buffer.
CSVArrayToString — Creates a CSV string from the Array with optional element count.
CSVSetExportFlags — Sets flags regarding the CSV export style.
CSVTableToString — Returns a CSV version of a table array (two-dimensional) with optional flags.
CSVWriteRecord — Writes the current CSV Object buffer to the specified Basic File Object handle.
CSVWriteTable — Writes a table array (2-axis) to a file by name or as a Basic File Object as CSV with optional line ending flag.
Clipboard:
ClipboardGetCSVData — Get CSV from clipboard as a string table.
ClipboardGetCSVText — Get CSV from clipboard as a CSV string.
ClipboardIsCSVAvailable — Tests for CSV being available on clipboard.
Data Sheet:
DataSheetExport — Exports the contents of a sheet to a file or pool.
DataSheetImport — Imports an XML (XDS) or CSV formatted data into Data Sheet Object.
DataSheetOpen — Creates and Data Sheet Object and loads the data from the file specified by filename.
Table of Contents | < < Previous | Next >> |
© 2012-2024 Novaworks, LLC. All rights reserved worldwide. Unauthorized use, duplication or transmission prohibited by law. Portions of the software are protected by US Patents 10,095,672, 10,706,221 and 11,210,456. GoFiler™ and Legato™ are trademarks of Novaworks, LLC. EDGAR® is a federally registered trademark of the U.S. Securities and Exchange Commission. Novaworks is not affiliated with or approved by the U.S. Securities and Exchange Commission. All other trademarks are property of their respective owners. Use of the features specified in this language are subject to terms, conditions and limitations of the Software License Agreement.