992a12b087b6cef00ad0f699d613f2abc538018b kent Thu Apr 20 17:46:28 2017 -0700 Moving some little new useful routines to library. diff --git src/lib/obscure.c src/lib/obscure.c index a0fa73d..19051a7 100644 --- src/lib/obscure.c +++ src/lib/obscure.c @@ -153,30 +153,43 @@ /* Given a two column file (key, value) return a hash. */ { struct lineFile *lf = lineFileOpen(fileName, TRUE); char *row[2]; struct hash *hash = hashNew(16); while (lineFileRow(lf, row)) { char *name = row[0]; char *value = lmCloneString(hash->lm, row[1]); hashAdd(hash, name, value); } lineFileClose(&lf); return hash; } +struct slPair *slPairTwoColumnFile(char *fileName) +/* Read in a two column file into an slPair list */ +{ +char *row[2]; +struct slPair *list = NULL; +struct lineFile *lf = lineFileOpen(fileName, TRUE); +while (lineFileRow(lf, row)) + slPairAdd(&list, row[0], cloneString(row[1])); +lineFileClose(&lf); +slReverse(&list); +return list; +} + struct slName *readAllLines(char *fileName) /* Read all lines of file into a list. (Removes trailing carriage return.) */ { struct lineFile *lf = lineFileOpen(fileName, TRUE); struct slName *list = NULL, *el; char *line; while (lineFileNext(lf, &line, NULL)) { el = newSlName(line); slAddHead(&list, el); } lineFileClose(&lf); slReverse(&list); return list;