table save, table save with local decimal separator, table save with decimal comma, table save multiple
This function saves 1 or more tables to a file. Following file formats are supported and can be specified in the 2nd function parameter:
CSV | Comma separated files | Uses list separation symbols according to locale settings. |
Text files | Plain text | Text files can be saved by using 'new line' as list separator. |
EXCEL | MS Excel XML 2003 Format | Excel compatible XML format which supports multiple tables in one file as well as styles. This format is obsolete. Attention: Use table save excel file() instead to save your work in modern Excel fromat with fie type '.xlsx' |
HTML | HTML format | Saves the table in a HTML file and supports styles. The HTML file can be opened with Excel and with web browsers. |
JSON | JavaScript Object Notation format | Saves the table in a JSON file. Various options exist. |
XML | XML (extended markup) file | (Not yet supported) |
For CSV files, the following function names save the files differently:
table save with local decimal separator will use the decimal symbol for numbers as specified in the locale setting. It's a comma for settings related to Germany.
table save with decimal comma will always use the comma as decimal separator symbol.
table save will always use the point as decimal separator symbol.
Note: No thousand separators will be used.
table save multiple is supported with following formats: HTML, EXCEL, JSON arrays and JSON objects, but not with CSV and TEXT.
Indirect parameter passing is disabled
2-6
No. | Type | Description | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1. input |
set or string | Name(s) of table(s) Provide 1 table as string unless the function table save multiple is used. | ||||||||||||||||||||||||||
- / 2. input |
set or string | Sheet name(s) Only applicable for table save multiple: For each table provided in the 1st function parameter, a corresponding sheet name needs to be provided. When saving in Excel format, these sheet names will appar as tab names at the bottom of the displayed worksheets. | ||||||||||||||||||||||||||
2. / 3. input |
string | File name Specify the file name. Add the path in front if the file is not located in the current working directory. | ||||||||||||||||||||||||||
Opt. 3. / 4. input |
string | Format descriptor
| ||||||||||||||||||||||||||
Opt. 4. / 5. input |
string | Character set
Attention: Put the values into quotation marks if they contain a hyphen, otherwise the hyphen is interpreted as a minus sign. Advice: If the file has an exotic character set, consider using "win1252" for full 8-bit character space, and interprete the character codes on your own. Default value: utf-8 (UNICODE) | ||||||||||||||||||||||||||
Opt. 5. / 6. input |
string | Option At present, one option is defined in addition to the default option:
|
Type | Description |
---|---|
boolean | Success If not successul, then an exception has happened |
Path not found
File not accessible
File locked
Syntax errors in table formats, e.g in HTML, JSON, XML
File locked. Close the file in the other application and retry
table initialize( t, { { Object, Height in meters }, { dog, 0.5 }, { horse, 1.8 }, { elephant, 2.5 }} );
table list ( t ); echo;
table save( t, animals.csv, CSV );
table load( t, animals.csv, ";" );
table list ( t ); echo;
table load( t, animals.csv, "," );
echo("Table loaded with wrong separator symbol. Outcome looks like this:");
table list ( t ); echo;
file delete silently( animals.csv );
0 : Object | Height in meters
1 : dog | 0.5
2 : horse | 1.8
3 : elephant | 2.5
0 : Object | Height in meters
1 : dog | 0.5
2 : horse | 1.8
3 : elephant | 2.5
Table loaded with wrong separator symbol. Outcome looks like this:
0 : Object;Height in meters
1 : dog;0.5
2 : horse;1.8
3 : elephant;2.5