da_read_csv_?() - 5.2 English - 68552

AOCL API Guide (68552)

Document ID
68552
Release Date
2025-12-29
Version
5.2 English
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_cols array of data read from the CSV file. Data is stored in column-major order, unless you have set the storage order option to row-major. Note that this routine allocates memory for A internally. 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_cols array of strings containing the column headings. If the option use header row is set to 0 (the default) then this argument is not used. Otherwise, note that this routine allocates memory for headings internally. You can call da_delete_string_array to deallocate this memory.

Returns:

da_status. The function returns:

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_cols array of data read from the CSV file. Data is stored in column-major order, unless you have set the storage order option to row-major. Note that this routine allocates memory for A internally. 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_cols array of strings containing the column headings. If the option use header row is set to 0 (the default) then this argument is not used. Otherwise, note that this routine allocates memory for headings internally. You can call da_delete_string_array to deallocate this memory.

Returns:

da_status. The function returns:

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_cols array of data read from the CSV file. Data is stored in column-major order, unless you have set the storage order option to row-major. Note that this routine allocates memory for A internally. You can call da_delete_string_array 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_cols array of strings containing the column headings. If the option use header row is set to 0 (the default) then this argument is not used. Otherwise, note that this routine allocates memory for headings internally. You can call da_delete_string_array to deallocate this memory.

Returns:

da_status. The function returns:

For reading data directly into a da_datastore struct, see da_data_load_from_csv().