Skip to content

Commit

Permalink
Merge branch 'develop' into validation
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfrantz committed Jan 31, 2024
2 parents 9b90e9a + 1653e22 commit c849863
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/cross-level/table-cl.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,42 @@ table_t table;
}


/** This function returns the column of a given column name
--- table: table
--- name: column name
+++ Return: column index, or -1 if unsuccessful
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**/
int find_table_col(table_t *table, const char *name){
int col;

if (table->has_col_names){
for (col=0; col<table->ncol; col++){
if (strcmp(table->col_names[col], name) == 0) return col;
}
}

return -1;
}


/** This function returns the row of a given row name
--- table: table
--- name: row name
+++ Return: row index, or -1 if unsuccessful
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**/
int find_table_row(table_t *table, const char *name){
int row;

if (table->has_row_names){
for (row=0; row<table->nrow; row++){
if (strcmp(table->row_names[row], name) == 0) return row;
}
}

return -1;
}


/** This function prints a table.
--- table: table
+++ Return: void
Expand Down
2 changes: 2 additions & 0 deletions src/cross-level/table-cl.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ typedef struct {

table_t read_table(char *fname, bool has_row_names, bool has_col_names);
table_t allocate_table(int nrow, int ncol, bool has_row_names, bool has_col_names);
int find_table_col(table_t *table, const char *name);
int find_table_row(table_t *table, const char *name);
void init_table(table_t *table);
void print_table(table_t *table, bool truncate);
void write_table(table_t *table, char *fname, const char *separator, bool skip_rows);
Expand Down

0 comments on commit c849863

Please sign in to comment.