Porovnávané verzie

Kľúč

  • Tento riadok sa pridal
  • Riadok je odstránený.
  • Formátovanie sa zmenilo.
Komentár: parameter timeZone

EXPORT_CSV action


Function
Export of a row, column or whole structured local variable (i.e. local variable of Record type) into a CSV file.
Declaration


Blok kódu
languageesl
themeConfluence
 EXPORT_CSV toExportStruct, delimiter, fName, bMonoTimestimeZone, retCodeIdent_Int[, transPalIdx_Int] [TIME] [UTF8] | ENCODING "@APP_DEFAULT@"] [APPEND]
Parameters


toExportStructinRow identifier, column identifier or identifier of local variable of Record type.
delimiterinIdentifier of Text type - delimiter to be used in the CSV file.
fNameinFile name with extension.
bMonoTimes
timeZoneinParameter of
Bool type. Method for work with time (monotonic time attribute).
Text, Int or Bool type - defines interpretation of timestamps.
retCodeIdent_IntoutReturn value of Int type - action success.
transPalIdxinOptional parameter of Int type.
TIMEinKey word.
UTF8inKey word.
ENCODINGinKey word which is followed by a name of file encoding in the text format. The list of supported encodings in ESL.
APPENDinKey word.
Description
The action generates a file of CSV format. File name is given by the parameter fName. Item delimiter in the CSV file is specified by the parameter delimiter.
The action success is indicated by the output parameter retCodeIdent_Int. Value of 0 means the successful export, the value other than 0 means the error.

Depending on the parameter toExportStruct, the action exports:
  • entire local variable
  • row of local variable
  • column of local variable

CSV file format
The local variable is saved to the specified CSV file row-by-row (row in a structure presents a row in a CSV file).
Because the CSV file format is not unique defined, the action awaits a delimiter as its second parameter. Delimiter is one character, that is to be used to separate items in the CSV file. Real numbers use the decimal separator '.'.

If the key word
Blok kódu
languageesl
themeConfluence
 TIME

is used, then the CSV file also contains the value time for each item. Time is presented before the item value. CSV file therefore contains the double number of columns.
If the key word UTF8 is used, the action generates a text file with UTF-8 encoding.
If the key word APPEND is used, the action inserts data into CSV file. In case that this file does not exist, it will be created.

Kotva
cas_format
cas_format
Time can be formatted by the mask defined in the transformation palette - the index is given by parameter transPalIdx_Int.
If the parameter is not defined or its value is 0, there is used the mask dd.mm.rrrr hh:mi:ss.
If its value is -1, then values of Absolute time and Real types are to be converted according to the settings specified in the Regional and Language Options of the current user on Windows systems. For different operating systems the value of -1 will be automatically replaced with the value of 0.

The parameter

bMonoTimes allows to specify whether daylight-saving changes are accepted or not. If the value of the parameter is @TRUE, all time values are to be recalculated in monotonic time (not in daylight-saving time)

timeZone defines export interpretation of timestamps. In case of empty text, timestamps are exported as local times. In case of defined time zone name (e.g. "Europe/London"), timestamps are exported as local times for given time zone. In case of integer value, timestamps are exported as times with fixed offset from UTC, where given value defines offset in seconds. For historical reasons boolean values are accepted: @FALSE - timestamps are exported as local times, @TRUE - timestamps are exported as times with fixed offset of 3600 seconds (1 hour) from UTC. Usage of boolean value @TRUE is not recommended and generates warning when ESL script is being saved. It is recommended to replace it with integer value.

The CSV delimiter (the parameter delimiter) may be obtained by calling the function %GetCSVDelimiter.

Example
Assumes:

The object SD.ArchVal of Structure definition is defined with the columns:

NameType
ValueReal
FlagsInteger

There is defined the object SV.ArchVal of Structured variable. The structure type is SD.ArchVal. The number of rows: 3. Start values are:

ValueFlags
1.23
22
31

The example does not test the action execution success.

 


Blok kódu
languageesl
themeRDark
RECORD (SD.ArchVal) _rec


Blok kódu
languageesl
themeRDark
REDIM _rec[SV.ArchVal\DIM]
 SET _rec WITH SV.ArchVal
 
 EXPORT_CSV _rec, ';', "c:\rec.csv", @TRUE, _retCode
 EXPORT_CSV _rec[1], ';', "c:\rec1.csv", @TRUE, _retCode
 EXPORT_CSV _rec^Value, ';', "c:\recValue.csv", @TRUE, _retCode
 
The actions exports the local variable _rec, that contains a copy of SV.ArchVal.
Created files:


c:\rec.csv

 


Blok kódu
languageesl
themeRDark
1,20000000000000;3
 2,00000000000000;2
 3,00000000000000;1
 
c:\rec1.csv
 


Blok kódu
languageesl
themeRDark
1,20000000000000;3
 
 
c:\recValue.csv
 


Blok kódu
languageesl
themeRDark
1,20000000000000
 2,00000000000000
 3,00000000000000

Info
titleRelated pages:

Script actions