4e8f4786b04d81ae75cab0f10412847cbcf1aa6a braney Wed May 11 10:30:41 2022 -0700 change fieldedTable to require the same number of tab separated fields on every line. diff --git src/lib/fieldedTable.c src/lib/fieldedTable.c index 73a9904..ae34be5 100644 --- src/lib/fieldedTable.c +++ src/lib/fieldedTable.c @@ -242,34 +242,36 @@ errAbort("%s is missing required field '%s'", lf->fileName, required); } /* Create fieldedTable . */ struct fieldedTable *table = fieldedTableNew(lf->fileName, fields, fieldCount); table->startsSharp = startsSharp; return table; } struct fieldedTable *fieldedTableAttach(struct lineFile *lf, char *requiredFields[], int requiredCount) /* Read table from tab-separated file with a #header line that defines the fields * from already open lineFile.. Ensures all requiredFields (if any) are present. * should be NULL for most purposes. */ { struct fieldedTable *table = fieldedTableReadTabHeader(lf, requiredFields, requiredCount); -char *row[table->fieldCount]; -while (lineFileNextRowTab(lf, row, table->fieldCount)) +char numColumns = table->fieldCount + 1; // + 1 so we'll see lines that are too long +char *row[numColumns]; +int wordsRead; +while ((wordsRead = lineFileChopNextTab(lf, row, numColumns)) != 0) { - fieldedTableAdd(table, row, table->fieldCount, lf->lineIx); + fieldedTableAdd(table, row, wordsRead, lf->lineIx); } return table; } struct fieldedTable *fieldedTableFromTabFile(char *fileName, char *reportFileName, 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 reportFileName is just used for error reporting and * should be NULL for most purposes. This is used by edwSubmit though which * first copies to a local file, and we want to report errors from the remote file. * We do know the remote file exists at least, because we just copied it. */ { /* Open file with fileName */ struct lineFile *lf = netLineFileOpen(fileName);