- Vytvoril D2000 Dev Team na nov 24, 2022
EXPORT_CSV_TEXT action
EXPORT_CSV_TEXT toExportStruct, delimiter, outputIdent_Text, timeZone, retCodeIdent_Int[, transPalIdx_Int] [TIME]
toExportStruct | in | Row identifier, column identifier or identifier of local variable of Record type. |
delimiter | in | Identifier of Text type - delimiter to be used in the CSV file. |
timeZone | in | Parameter of Text, Int or Bool type - defines interpretation of timestamps. |
retCodeIdent_Int | out | Return value of Int type - action success. |
transPalIdx | in | Optional parameter of Int type. |
outputIdent_Text | out | Export result of Text type |
TIME | in | Keyword. |
The action success is indicated by the output parameter retCodeIdent_Int. The value of 0 means a successful export, values other than 0 are an error.
Depending on the parameter toExportStruct, the action exports:
- the entire local variable
- the row of local variable
- the column of local variable
CSV format
The local variable is saved to the specified CSV row-by-row (row in a structure presents a row in a CSV).
Because the CSV 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 string. Real numbers use the decimal separator '.'.
If the keyword
TIME
is used, then the CSV string also contains the value time for each item. Time is presented before the item value. CSV string therefore contains the double number of columns.
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 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.
The object SD.ArchVal of Structure definition is defined with the columns:
Name | Type |
Value | Real |
Flags | Integer |
There is defined the object SV.ArchVal of Structured variable. The structure type is SD.ArchVal. The number of rows: 3. Start values are:
Value | Flags |
1.2 | 3 |
2 | 2 |
3 | 1 |
The example does not test the action execution success.
RECORD (SD.ArchVal) _rec
REDIM _rec[SV.ArchVal\DIM] SET _rec WITH SV.ArchVal EXPORT_CSV _rec, ';', _output1, @TRUE, _retCode EXPORT_CSV _rec[1], ';', _output2, @TRUE, _retCode EXPORT_CSV _rec^Value, ';', _output3, @TRUE, _retCode
Content of variables:
_output1
1,20000000000000;3 2,00000000000000;2 3,00000000000000;1
1,20000000000000;3
1,20000000000000 2,00000000000000 3,00000000000000
Related pages:
Pridať komentár