<<

Contents

Search

>>

 

EXPORT_CSV

 

 

Function

 

 

Syntax:

EXPORT_CSV(<Name of Index File>,<Number of Key>,<Name of CSV File>,<Column Headers>,<Field Numbers>,<Separator>,<Date Format>,<Apostrophe> [,<Macroname>])

 

<Name of Index File>

= <INDEX FILE>

<Number of Key>

= <NUM-EXPRESSION>

<Name of CSV File>

= <STRING-EXPRESSION >

<Column Headers>

= <STRING-EXPRESSION >

<Field Numbers>

= <STRING-EXPRESSION >

<Separator>

= <STRING-EXPRESSION >

<Date Format>

= <STRING-EXPRESSION >

<Apostrophe>

= <NUM-EXPRESSION >

<Macroname>

= <MACRONAME>

 

 

Meaning:

EXPORT_CSV exports data records from the Index File <Name of Index File> into a CSV file.

 

<Number of Key> specifies the number of the key (0 = Primary key, 1,... = Secondary key) by which the Index File is read. First, a START or STARTS is executed in the Index File with the key = <Number of Key>. Before EXPORT_CSV is called, the appropriate values for the first data record to be exported have ro be assigned to the key fields. All Following data records of the Index File are read with READ-NEXT or READS-NEXT. <Number of Key> can be a variable or a numeric expression.

 

If <Number of Key> < 0, the Index File is not read by START / START and READ-NEXT / READS-NEXT, but by GET_FIRST_RECORD and GET_NEXT_RECORD. This increases speed. But in this case all data records of the Index File are exported. If <Number of Key> >= 0, the export starts at the current data record of the Index File which is specified by the selected key.

 

If <Number of Key> > 0 and the key does not exist, EXPORT_CSV returns the result -5.

 

<Name of CSV File> contains the name of the CSV file into which the data records are exported.

 

<Column Headers> contains the column headers, which are written into the first line of the CSV file. The headers are separated by <Separator>. If <Column Headers> is the empty string ²², the field names are used as column headers. If <Column Headers> consists of blanks only (one or several blanks), no heading is written into the CSV file.

 

<Field Numbers> contains the numbers of the fields that are to be exported. The numbers are separated by semi-colons. If <Field Numbers> is the empty string ²², all fields of the Index File are exported.

 

<Separator> specifies the separator in the CSV file. If <Separator> is the empty string ²², the separator is a semi-colon ; .

 

<Date Format> specifies the format in which date fields are to be exported. (e.g. MM.DD.YYYY or YYYY.MM.DD). If <Date Format> is the empty string ²², the records are exported in the format YYYYMMDD.

 

If <Apostrophe> <> 0, the data fields are put into inverted commas ²...². 

 

If a <Macroname> is specified, the macro is executed before the current data record is exported. If EBUS_DATA = 0 in the macro, the current data record is not exported and the next data record is processed. If  EBUS_DATA = , the current data record is not exported and the processing is finished. 

 

EXPORT_CSV returns the following results:

 

Result

Meaning

1

No error

-1

Index File does not exist.

-2

No data found.

-3

Index File is corrupt.

-4

Error opening CSV file. OK contains the error number, ERRORTEXT$ contains the error text.

-5

Key <Number of Key> does not exist.

 

Parameter:

Name of Index File

Name of Index File

Number of Key

Number of key of the Index File: 0 = Primary key, 1,... = Secondary key

Name of CSV File

Name of CSV File

Column Headers

Contains the columns headers separated by colon

Field Numbers

Contains the numbers of the field which shall be exported.

Separator

Contains the separator of the CSV file.

Date Format

Contains the date format.

Apostrophe

Specifies whether the field values are put into inverted commas ²...².

0 = no inverted commas

otherwise = all field values are put into inverted commas.

Macroname

Name of the macro which is called before the current data record is exported.

 

Sample:

// Export all data records of all Index Files

FOR I%=1 TO EBUS_FILENAME_SIZE

    FILE$ = LOWER$(NOBLANK$(1,EBUS_FILENAME$(I%)))

    INITIALIZE FILE$

    H% = EXPORT_CSV(FILE$,0,DATEI$+".csv","","",CHR$(9),"MM-DD-YYYY",0)

    IF H% <> 1

    THEN ERRORMES = "Error " + STR$(H%) + " with file " + FILE$ +

                    ": " + ERRORTEXT$

    ENDIF

ENDLOOP

 

See also:

COPY_JDBC_INDEXFILE_TO_EBUS

COPY_EBUS_INDEXFILE_TO_JDBC

EBUS_DATA