CSV Reading APIs#
da_read_csv_?()#
-
da_status da_read_csv_d(da_datastore store, const char *filename, double **A, da_int *n_rows, da_int *n_cols, char ***headings)#
-
da_status da_read_csv_s(da_datastore store, const char *filename, float **A, da_int *n_rows, da_int *n_cols, char ***headings)#
-
da_status da_read_csv_int(da_datastore store, const char *filename, da_int **A, da_int *n_rows, da_int *n_cols, char ***headings)#
Read data of a single type from a CSV file, optionally with a header row containing the column labels.
- Parameters
store – [inout] a da_datastore object, initialized using da_datastore_init.
filename – [in] the relative or absolute path to a file or stream that can be opened for reading.
A – [out] a pointer to the
n_rows\(\times\)n_colsarray of data read from the CSV file. Data is stored in column major order, unless you have set the CSV data storage option to row major. Note that this routine allocates memory forAinternally. It is your responsibility to deallocate this memory.n_rows – [out] the number of rows loaded.
n_cols – [out] the number of columns loaded.
headings – [out] a pointer to the size
n_colsarray of strings containing the column headings. If the option CSV use header row is set to 0 (the default) then this argument is not used. Otherwise, note that this routine allocates memory forheadingsinternally. It is your responsibility to deallocate this memory.
- Returns
da_status. The function returns:
da_status_success - the operation was successfully completed.
da_status_file_reading_error - the file could not be opened.
da_status_parsing_error - use da_datastore_print_error_message to obtain further information.
da_status_missing_data - use da_datastore_print_error_message to obtain further information.
-
da_status da_read_csv_uint8(da_datastore store, const char *filename, uint8_t **A, da_int *n_rows, da_int *n_cols, char ***headings)#
Read boolean data from a CSV file, optionally with a header row containing the column labels.
This routine reads files consisting of the (case-insensitive) words True and False and stores them in an array of type uint8_t containing the values 1 or 0 respectively.
- Parameters
store – [inout] a da_datastore object, initialized using da_datastore_init.
filename – [in] the relative or absolute path to a file or stream that can be opened for reading.
A – [out] a pointer to the
n_rows\(\times\)n_colsarray of data read from the CSV file. Data is stored in column major order, unless you have set the CSV data storage option to row major. Note that this routine allocates memory forAinternally. It is your responsibility to deallocate this memory.n_rows – [out] the number of rows loaded.
n_cols – [out] the number of columns loaded.
headings – [out] a pointer to the size
n_colsarray of strings containing the column headings. If the option CSV use header row is set to 0 (the default) then this argument is not used. Otherwise, note that this routine allocates memory forheadingsinternally. It is your responsibility to deallocate this memory.
- Returns
da_status. The function returns:
da_status_success - the operation was successfully completed.
da_status_file_reading_error - the file could not be opened.
da_status_parsing_error - use da_datastore_print_error_message to obtain further information.
da_status_missing_data - use da_datastore_print_error_message to obtain further information.
-
da_status da_read_csv_string(da_datastore store, const char *filename, char ***A, da_int *n_rows, da_int *n_cols, char ***headings)#
Read char string data from a CSV file, optionally with a header row containing the column labels.
This routine reads files consisting of character data and stores them in an array of type char* character strings.
- Parameters
store – [inout] a da_datastore object, initialized using da_datastore_init.
filename – [in] the relative or absolute path to a file or stream that can be opened for reading.
A – [out] a pointer to the
n_rows\(\times\)n_colsarray of data read from the CSV file. Data is stored in column major order, unless you have set the CSV data storage option to row major. Note that this routine allocates memory forAinternally. It is your responsibility to deallocate this memory.n_rows – [out] the number of rows loaded.
n_cols – [out] the number of columns loaded.
headings – [out] a pointer to the size
n_colsarray of strings containing the column headings. If the option CSV use header row is set to 0 (the default) then this argument is not used. Otherwise, note that this routine allocates memory forheadingsinternally. It is your responsibility to deallocate this memory.
- Returns
da_status. The function returns:
da_status_success - the operation was successfully completed.
da_status_file_reading_error - the file could not be opened.
da_status_parsing_error - use da_datastore_print_error_message to obtain further information.
da_status_missing_data - use da_datastore_print_error_message to obtain further information.
For reading data directly into a da_datastore struct, see da_data_load_from_csv().