2e2fe42ea116b0a37fe3bd4b1744a0998a4ccaa6 kent Fri Jun 2 14:24:09 2017 -0700 Adding csvParse. diff --git src/lib/csv.c src/lib/csv.c index c5287d1..4cb5d5a 100644 --- src/lib/csv.c +++ src/lib/csv.c @@ -135,15 +135,29 @@ } // Update position to start reading next one from and return scratchpad *pos = s; return scratch->string; } boolean csvNeedsParsing(char *s) /* Return TRUE if s is something that needs parsing through the csv parser. That * is it either starts with a quote or has a comma */ { if (strchr(s, ',')) return TRUE; return *s == '"'; } + +struct slName *csvParse(char *csv) +/* Return a list of parsed out csv values. Do a slFreeList of this when done */ +{ +struct dyString *scratch = dyStringNew(0); +struct slName *list = NULL; +char *val; +while ((val = csvParseNext(&csv, scratch)) != NULL) + slNameAddHead(&list, val); +dyStringFree(&scratch); +slReverse(&list); +return list; +} +