8ca78d3a7a71282970c6cefd998a19504271d520 angie Tue Mar 15 18:23:41 2022 -0700 In hashTwoColumnFile, first check if the input is tab-separated so we can tolerate spaces in the second column. If no tabs, then fall back to space-separated. diff --git src/lib/obscure.c src/lib/obscure.c index 1c05208..f4d5f5e 100644 --- src/lib/obscure.c +++ src/lib/obscure.c @@ -145,32 +145,38 @@ char *row[2]; struct hash *hash = hashNew(16); while (lineFileRow(lf, row)) hashAddInt(hash, row[0], lineFileNeedNum(lf, row, 1)); lineFileClose(&lf); return hash; } struct hash *hashTwoColumnFile(char *fileName) /* Given a two column file (key, value) return a hash. */ { struct lineFile *lf = lineFileOpen(fileName, TRUE); struct hash *hash = hashNew(16); char *row[3]; int fields = 0; -while ((fields = lineFileChop(lf, row)) != 0) +// Try tab-separated first; if no tabs, then try whitespace-separated. +while ((fields = lineFileChopTab(lf, row)) != 0) { + if (fields == 1) + { + char *line = row[0]; + fields = chopLine(line, row); + } lineFileExpectWords(lf, 2, fields); char *name = row[0]; char *value = lmCloneString(hash->lm, row[1]); hashAdd(hash, name, value); } lineFileClose(&lf); return hash; } struct hash *hashTsvBy(char *in, int keyColIx, int *retColCount) /* Return a hash of rows keyed by the given column */ { struct lineFile *lf = lineFileOpen(in, TRUE); struct hash *hash = hashNew(0); char *line = NULL, **row = NULL;