#include <eh_utils.h>
Go to the source code of this file.
Functions | |
gchar * | eh_dlm_prepare (const gchar *file, GError **err) |
double ** | eh_dlm_read_data (gchar *str, gchar *delims, gint *n_rows, gint *n_cols, GError **err) |
gint | eh_dlm_find_n_cols (gchar *content, gchar *delims) |
gint | eh_dlm_find_n_rows (gchar *content, gint delim) |
gchar ** | eh_dlm_split_records (gchar *str, const gchar *start_str, const gchar *end_str, gchar ***rec_data) |
double ** | eh_dlm_read (const gchar *file, gchar *delims, gint *n_rows, gint *n_cols, GError **err) |
double ** | eh_dlm_read_swap (const gchar *file, gchar *delims, gint *n_rows, gint *n_cols, GError **err) |
double *** | eh_dlm_read_full (const gchar *file, gchar *delims, gint **n_rows, gint **n_cols, gchar ***rec_data, gint max_records, GError **err) |
double *** | eh_dlm_read_full_swap (const gchar *file, gchar *delims, gint **n_rows, gint **n_cols, gchar ***rec_data, gint max_records, GError **err) |
gchar * | eh_dlm_remove_empty_lines (gchar *str) |
gint | eh_dlm_print (const gchar *file, const gchar *delim, const double **data, const gint n_rows, const gint n_cols, GError **error) |
gint | eh_dlm_print_swap (const gchar *file, const gchar *delim, const double **data, const gint n_rows, const gint n_cols, GError **error) |
gint | eh_dlm_print_full (const gchar *file, const gchar *delim, const double **data, const gint n_rows, const gint n_cols, gboolean swap, GError **error) |
gint | eh_dlm_print_dbl_grid (const gchar *file, const gchar *delim, Eh_dbl_grid g, GError **error) |
gint eh_dlm_find_n_cols | ( | gchar * | content, | |
gchar * | delims | |||
) |
Definition at line 371 of file eh_dlm_file.c.
References eh_str_count_chr().
Referenced by eh_dlm_read_data().
gint eh_dlm_find_n_rows | ( | gchar * | content, | |
gint | delim | |||
) |
Definition at line 358 of file eh_dlm_file.c.
References eh_str_count_chr().
Referenced by eh_dlm_read_data().
gchar * eh_dlm_prepare | ( | const gchar * | file, | |
GError ** | err | |||
) |
Definition at line 21 of file eh_dlm_file.c.
References eh_dlm_remove_empty_lines(), eh_return_val_if_fail, eh_str_remove_c_style_comments(), eh_str_remove_to_eol_comments(), and eh_str_replace().
Referenced by eh_dlm_read_full().
gint eh_dlm_print | ( | const gchar * | file, | |
const gchar * | delim, | |||
const double ** | data, | |||
const gint | n_rows, | |||
const gint | n_cols, | |||
GError ** | error | |||
) |
Definition at line 530 of file eh_dlm_file.c.
References eh_dlm_print_full().
Referenced by _print_sediment_column(), bio_print_layers(), and eh_dlm_print_dbl_grid().
gint eh_dlm_print_dbl_grid | ( | const gchar * | file, | |
const gchar * | delim, | |||
Eh_dbl_grid | g, | |||
GError ** | error | |||
) |
Definition at line 596 of file eh_dlm_file.c.
References eh_dbl_grid_data(), eh_dlm_print(), eh_grid_n_x(), eh_grid_n_y(), eh_require, and eh_return_val_if_fail.
Referenced by main().
gint eh_dlm_print_full | ( | const gchar * | file, | |
const gchar * | delim, | |||
const double ** | data, | |||
const gint | n_rows, | |||
const gint | n_cols, | |||
gboolean | swap, | |||
GError ** | error | |||
) |
Definition at line 542 of file eh_dlm_file.c.
References eh_fopen_error(), eh_require, and eh_return_val_if_fail.
Referenced by eh_dlm_print(), and eh_dlm_print_swap().
gint eh_dlm_print_swap | ( | const gchar * | file, | |
const gchar * | delim, | |||
const double ** | data, | |||
const gint | n_rows, | |||
const gint | n_cols, | |||
GError ** | error | |||
) |
Definition at line 536 of file eh_dlm_file.c.
References eh_dlm_print_full().
Referenced by bio_print_output().
double** eh_dlm_read | ( | const gchar * | file, | |
gchar * | delims, | |||
gint * | n_rows, | |||
gint * | n_cols, | |||
GError ** | err | |||
) |
Read a delimited file
Read data from the ASCII file file
. Data are written row-by-row with each column delimited by any of the characters contained in delims
. The number of columns is determined by the line with the largest number of elements. Rows with fewer columns are padded with zeros.
file | The name of the data file | |
delims | A string of possible delimeters | |
n_rows | Location to put the number of rows read | |
n_cols | Location to put the number of columns read | |
err | Retrun location for a GError, or NULL |
Definition at line 67 of file eh_dlm_file.c.
References eh_dlm_read_full(), eh_free, and eh_return_val_if_fail.
Referenced by _scan_sediment_column(), avulsion_full(), eh_dlm_read_swap(), and sed_bathy_grid_scan_2d_ascii().
double ** eh_dlm_read_data | ( | gchar * | str, | |
gchar * | delims, | |||
gint * | n_rows, | |||
gint * | n_cols, | |||
GError ** | err | |||
) |
Definition at line 301 of file eh_dlm_file.c.
References eh_dlm_find_n_cols(), eh_dlm_find_n_rows(), eh_new_2, and eh_return_val_if_fail.
Referenced by eh_dlm_read_full().
double*** eh_dlm_read_full | ( | const gchar * | file, | |
gchar * | delims, | |||
gint ** | n_rows, | |||
gint ** | n_cols, | |||
gchar *** | rec_data, | |||
gint | max_records, | |||
GError ** | err | |||
) |
Read multiple records from a text delimited file
Similar to eh_dlm_read except that multiple records can be present within the text file. Records begin with a head that is enclosed by square brackets. The data are read with the same format as that used by eh_dlm_read.
file | The name of the data file | |
delims | A string of possible delimeters | |
n_rows | Location to put the array of number of rows read | |
n_cols | Location to put the array of number of columns read | |
rec_data | Location to hold a NULL-terminated array header strings | |
max_records | If greater than 0, the maximum number of records to scan. If less than 0, all of the records will be scanned. | |
err | Retrun location for a GError, or NULL |
Definition at line 181 of file eh_dlm_file.c.
References eh_dlm_prepare(), eh_dlm_read_data(), eh_dlm_split_records(), eh_free, eh_new, and eh_return_val_if_fail.
Referenced by eh_dlm_read(), and eh_dlm_read_full_swap().
double*** eh_dlm_read_full_swap | ( | const gchar * | file, | |
gchar * | delims, | |||
gint ** | n_rows, | |||
gint ** | n_cols, | |||
gchar *** | rec_data, | |||
gint | max_records, | |||
GError ** | err | |||
) |
Read multiple records from a text delimited file and swap rows and columns
Same as eh_dlm_read_full except that the rows and columns of the output matrices are swapped.
file | The name of the data file | |
delims | A string of possible delimeters | |
n_rows | Location to put the array of number of rows read | |
n_cols | Location to put the array of number of columns read | |
rec_data | Location to hold a NULL-terminated array header strings | |
max_records | If greater than 0, the maximum number of records to scan. If less than 0, all of the records will be scanned. | |
err | Retrun location for a GError, or NULL |
Definition at line 255 of file eh_dlm_file.c.
References eh_dlm_read_full(), eh_free, eh_free_2, eh_new, eh_new_2, eh_return_val_if_fail, and EH_SWAP_PTR.
Referenced by sed_get_floor_sequence_2().
double** eh_dlm_read_swap | ( | const gchar * | file, | |
gchar * | delims, | |||
gint * | n_rows, | |||
gint * | n_cols, | |||
GError ** | err | |||
) |
Read a delimited file and swap rows and columns
Same as eh_dlm_read except that the rows and columns are swapped. That is, what were columns in the file are now rows in the returned matrix.
file | The name of the data file | |
delims | A string of possible delimeters | |
n_rows | Location to put the number of rows read | |
n_cols | Location to put the number of columns read | |
err | Retrun location for a GError, or NULL |
Definition at line 119 of file eh_dlm_file.c.
References eh_dlm_read(), eh_free_2, eh_new_2, and eh_return_val_if_fail.
Referenced by bio_scan_column_file(), eh_input_val_set(), inflow_scan_bathy_file(), sakura_scan_bathy_file(), sed_bathy_grid_scan_1d_ascii(), and sed_scan_sea_level_curve().
gchar* eh_dlm_remove_empty_lines | ( | gchar * | str | ) |
Remove empty lines from a string
This function does not allocate or reallocate any memory. It modifies str
in place. The pointer to str
is returned to allow the nesting of functions.
str | A string to remove empty lines from. |
str
Definition at line 414 of file eh_dlm_file.c.
References eh_free, eh_new0, and eh_str_remove_blocks().
Referenced by eh_dlm_prepare().
gchar ** eh_dlm_split_records | ( | gchar * | str, | |
const gchar * | start_str, | |||
const gchar * | end_str, | |||
gchar *** | rec_data | |||
) |
Definition at line 459 of file eh_dlm_file.c.
References eh_require, and eh_strv_append().
Referenced by eh_dlm_read_full().