Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5b

Application v 5.24b

  

 

Chapter EightData Functions (continued)

CSVReadTable Function

Overview

The CSVReadTable function reads the entire contents of a file into a two-dimensional table.

Syntax/Parameters

Syntax

float[][] = CSVReadTable ( handle hFile | string name, [dword flags] );

int[][] = CSVReadTable ( handle hFile | string name, [dword flags] );

string[][] = CSVReadTable ( handle hFile | string name, [dword flags] ); 

Parameters

hFile

A handle for a Basic File Object, or

name

A string specifying a fully qualified filename to read or a string containing CSV data.

flags

An optional dword that specifies various options. The default is 0x00000000, or nothing. The flags parameter can be set to CSV_WT_KEY_NAMES_TO_HEADER and the first line will be treated as key names.

Return Value

Returns an array of float, int, or string tables containing a copy of the CSV text or an empty array on failure. Use the GetLastError function to retrieve error information.

For non-string types, the data must be converted to the destination type. As such, the last error should be checked for ERROR_SYNTAX. The low word of the formatted error code will contain the syntax error count. The last error message will contain the location of the first error.

Remarks

Note that this function does not require a handle to a CSV Object. The data is read into a string table which can be managed through array functionality.

If CSV data is provided for the name parameter, it must contain at least one full record end with a line break.

If the destination is not a string type, it is possible to have type data type errors if the data in the CSV file does not match the incoming data type. If an error occurs, it is set into the last error code and message. The error message from the script engine will contain the zero based position within the destination array.

If the incoming data is UTF-8, the header is removed and the last error will contain CSV_WT_ADD_UTF_8_HEADER flag.

The flags parameter can be set to CSV_WT_KEY_NAMES_TO_HEADER and the first line will be treated as key names. The names must follow key naming convents and also cannot contain ‘{’ ‘}’ ‘,’ or ‘;‘ characters.

Related Functions

Platform Support

Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL

Legato IDE, Legato Basic