Added more error checking for ill-formed csv files
This commit is contained in:
parent
7b2563c5ae
commit
3df834565b
1 changed files with 8 additions and 1 deletions
|
|
@ -219,7 +219,7 @@ static int breakStrCommas(char* str, char** strlets, int maxPieces)
|
|||
/*
|
||||
* Here, we ensure consistency of the file
|
||||
* ntitleLines of any content
|
||||
* nColTitleLines of nCol columns. Each are separated by column
|
||||
* nColTitleLines of nCol columns. Each are separated by column.
|
||||
* nDataRows of nCol columns. Each are separated by columns
|
||||
* Each column is identified as either a text or double. Each double entry must be able to be read
|
||||
* as a double.
|
||||
|
|
@ -245,6 +245,13 @@ static void check_consistency(FILE* fp, const char *fileName, const int nTitleL
|
|||
exit(-1);
|
||||
}
|
||||
}
|
||||
if (nColTitleLines == 0) {
|
||||
if (nTitleLines > 0) {
|
||||
fprintf(stderr, "check_consistency() error for file %s, number column title lines are zero but number title lines are greater than 0",
|
||||
fileName);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < nColTitleLines; i++) {
|
||||
retn = read_line(fp, scanLine, 0);
|
||||
if (retn == -1) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue