e41713ca26a553b4fe04ba1e4bc311d92c4e6654 kent Sun Dec 27 19:11:34 2020 -0800 Adding a new routine, fieldedTableReadTabHeader, to allow matrix reading code to reuse some of fielded table diff --git src/inc/fieldedTable.h src/inc/fieldedTable.h index afab298..d792171 100644 --- src/inc/fieldedTable.h +++ src/inc/fieldedTable.h @@ -27,31 +27,38 @@ boolean startsSharp; /* Whether first line starts with a # char */ }; struct fieldedTable *fieldedTableNew(char *name, char **fields, int fieldCount); /* Create a new empty fieldedTable with given name, often a file name. */ void fieldedTableFree(struct fieldedTable **pTable); /* Free up memory resources associated with table. */ struct fieldedRow *fieldedTableAdd(struct fieldedTable *table, char **row, int rowSize, int id); /* Create a new row and add it to table. Return row. */ struct fieldedRow *fieldedTableAddHead(struct fieldedTable *table, char **row, int rowSize, int id); /* Create a new row and add it to start of table. Return row. */ -struct fieldedTable *fieldedTableFromTabFile(char *fileName, char *url, char *requiredFields[], int requiredCount); +struct fieldedTable *fieldedTableReadTabHeader(struct lineFile *lf, + char *requiredFields[], int requiredCount); +/* Read in first line of file treating it as a fieldedTable header line. + * Use lineFileNextRowTab(lf, row, table->fieldCount) on a row you provide + * that is table->fieldCount sized */ + +struct fieldedTable *fieldedTableFromTabFile(char *fileName, char *url, + char *requiredFields[], int requiredCount); /* Read table from tab-separated file with a #header line that defines the fields. Ensures * all requiredFields (if any) are present. The url is just used for error reporting and * should be the same as fileName for most purposes. This is used by edwSubmit though which * first copies to a local file, and we want to report errors from the url. */ void fieldedTableToTabFile(struct fieldedTable *table, char *fileName); /* Write out a fielded table back to file */ void fieldedTableToTabFileWithId(struct fieldedTable *table, char *fileName, char *idField, int startId); /* Write out a fielded table back to file. If idField is non-NULL it will be added * to the start of each output line as a steadily incrementing integer starting with startId. */ boolean fieldedTableColumnIsNumeric(struct fieldedTable *table, int fieldIx); /* Return TRUE if field has numeric values wherever non-null */