sFile | (String) File to read. Regardless of whether this parameter is set or not, it is possible to open the window for file selection by setting the fileselect parameter.
If a full path is not entered, then it is completed relative to the application folder. It is recommended to use the PROMOTIC path syntax - see PROMOTIC path to files or folders. |
---|---|
sFields | (String) Specifies which columns will be read from the file and of which data types the read data will be. For example "filecols:0,1,2,3;datatypes:string,double,string,string;".
filecols - Specifies which columns of the source CSV file will be included into the output array of values. If set filecols:all; (default), then all columns are included in the same order.
A list of numeric indexes - each column of the output array of values has the index (order) in the source CSV file. Each column of the output array can be read from any column of the source CSV file. It means that the list must have as many items as the resulting matrix number of columns. If set filecols:all; (default) then all columns are read. If set, for example, filecols:0,1,3,8;, then only those columns from the file that are stated here by index (zero-based index) are read. datatypes - The list of column data types of the output value array. The column data type specifies the way of reading data of the corresponding column of the CSV file. The defined column data types and the order must correspond with the output data array. It means that the list must contain as many items as is the number of columns of the output value array. The columns in the source CSV file may differ from the output value array, if the filecols column filter is used. Available data types of columns: string, byte, integer, bool, single, double. For example, datatypes:string,integer,bool,single;
If not set, then is string. |
sParams | (String) Specifies the way or reading the data from the file. For example "fileselect:yes;colnameheader:yes;delimiter:comma;"
"fileselect:xxx;" (optional)
yes - by calling the method the window for file selection is opened independently on setting the sFile parameter.
no (default) "colnameheader:xxx;" (optional)
yes - in the first row of the file there are no data but names of individual columns.
no (default) - already in the first row of the file the data are saved. "swap:xxx;" (optional)
yes (default) - columns from the file are saved as rows in the resulting matrix (in the data(i,j) cell there is the value of the i-th column and j-th row of the file).
no - rows from the file are saved as rows in the resulting matrix (in the data(i,j) cell there is the value of the i-th row and j-th column of the file). "delimiter:xxx;" (optional) - (only for CSV) The separator of values in the CSV file. The allowed values are:
semicolon (default) - the separator is a semicolon.
comma - the separator is a comma.
space - the separator is a space.
tab - the separator is a tab.
number - i.e. the separator is defined as a number of the ASCII character (in decimal), for example "delimiter:124;" means the "|" separator (vertical bar). "lastcolsep:xxx;" (optional)
yes - On 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. |
var vData = Pm.FileCsvRead("#app:data.csv", "filecols:all;", "delimiter:semicolon;colnameheader:no;fileselect:yes;");
if (Pm.IsValid(vData))
{
// ... If the data were read successfully
}
var sParams = "delimiter:semicolon;colnameheader:no;";
var vData = Pm.FileCsvRead("#app:data.csv", "filecols:0,3,1;datatypes:string,string,double;", sParams);
if (Pm.IsValid(vData))
{
// ... If the data were read successfully
}