Promotic
WikipediaLinkedInYoutubeTwitterFacebook

SaveToFile - method of object PmDataTable

Description:
Saving data of the object into the file of the CSV or DBF type. All columns and rows are saved.
Syntax:
SaveToFile(sFile As String, sParams As String) As Boolean
Calling:
b = oDataTable.SaveToFile(sFile, sParams)
Parameters:
sFile(String) File name (with path) into which the data have to be saved. If a full path is not entered, it is completed relatively according to the application file folder.

It is recommended to use the PROMOTIC path syntax - see PROMOTIC path to files and folders.

sParams(String) Text list of parameters that define the way of saving into the file. Entries with assigned value are separated by a semicolon, for example "filetype:csv;fmt:standard;".
"filetype:xxx;" (mandatory) - It defines the type of the file specified by the sFile parameter. The following file types are possible:
csv - type is a CSV file. It is the multi-lined file of text values separated, for example, by a semi-colon. It is commonly used, for example, in the MsExcel program.
dbf - the type is a DBF file in the dBASE III format. It is commonly used, for example, by the MsExcel program.
"fmt:xxx;" (optional) - It defines the format of the data stored in the file. The following formats are possible:
"standard" (default) - (only for CSV) values from rows of the CSV file are stored into corresponding rows in the table
"head:xxx;" (optional) - (only for CSV) It specifies if even the single-line heading with the columns names is stored in the file. The allowed values are:
no (default) - heading is not inserted.
name - heading is inserted, there are variable names in the heading.
"delimiter:xxx;" (optional) - (only for CSV) The separator of values in the CSV file. The allowed values are:
semicolon (default) - the delimiter is a semicolon.
comma - the delimiter is a comma.
space - the delimiter is a space.
tab - the delimiter is a tab.
number - i.e. the separator is defined as a decimal number of the ASCII character, for example "delimiter:124;" represents the "|" separator (vertical line).
"date.fmt:xxx;" (optional) - Date/time format. The allowed values are:
system (default) - the date/time format is set by OS Windows settings (e.g. 22.11.2010 16:30:15).
pm - PROMOTIC date/time format with 1 second accuracy (e.g. 2010.11.22 16:30:15).
pmmili - PROMOTIC date/time format with 1 millisecond accuracy (e.g. 2010.11.22 16:30:15.250).
real - data type of date/time format Date as a real number (e.g. 41392.123456789).
"real.dsep:xxx;" (optional) - (only for CSV) The format of decimal separator for real numbers. The allowed values are:
system (default) - the decimal separator is defined by OS Windows settings (e.g. 3,14).
dot - the decimal separator is (regardles on OS Windows settings) a period (e.g. 3.14).
comma - the decimal separator is (regardles on OS Windows settings) a comma (e.g. 3,14).
"lastcolsep:xxx;" (optional)
yes - When writing, the separator is added after the last value on the row, when reading, the empty value at the end of each row is ignored. From the CSV file standard point of view, this is not correct.
no (default) - The separators are present only between values on the same row, not at the end. From the CSV file standard point of view, this is correct.
"string.len:nnn;" (optional) - (only for DBF) maximum string lenght, default 32.
Return Values:
true - saving proceeded successfully
false - otherwise
Example1:
The data storage into the Data.csv file in application folder. The values will be separated by semicolon, the decimal separator of real numbers will be a period and the date will be stored in PROMOTIC system format.
oDataTable.SaveToFile"#app:Data.csv", "filetype:csv;delimiter:semicolon;real.dsep:dot;date.fmt:pm;"
Example2:
The data storage into the Data.csv file in application folder. The date will be stored in PROMOTIC system format.
oDataTable.SaveToFile"#app:Data.csv", "filetype:dbf;date.fmt:pmmili;"
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice