csv

Unnamed repository
Log | Files | Refs

commit f4971227e173e33192e78981170dce5af59ae180
parent eb5cc48c716d078349eda821bab263af80757fe3
Author: aabacchus <ben@bvnf.space>
Date:   Sat,  2 Oct 2021 16:17:41 +0100

check for missing cells

Diffstat:
Mcsv.c | 7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/csv.c b/csv.c @@ -61,7 +61,7 @@ read_data(FILE *f, float ***datap, int ncols) { if (c == ',' || c == '\n') { if (n == np) { /* nothing in this column */ - fprintf(stderr, "warning: empty cell at row %d, col %d\n", y + 1, x + 1); + fprintf(stderr, "warning: no value in cell at row %d, col %d\n", y + 1, x + 1); data[y][x] = 0.; } else { *np++ = '\0'; @@ -70,6 +70,11 @@ read_data(FILE *f, float ***datap, int ncols) { } x++; if (c == '\n') { + if (x < ncols) { + fprintf(stderr, "warning: %d cells missing from row %d\n", ncols - x, y + 1); + for (; x < ncols; x++) + data[y][x] = 0.; + } nrows++; y++; x = 0;