I'm reading a tab delimited csv file with fscanf.
The file was obtained from an SQL database where some columns were NULL. Accordingly, there are places where there is nothing in csv between tabs, and then fscanf goes astray and incorrectly produces a formatted record.
Is there any elegant way to check for missing values in a formatted entry?
struct Path {
unsigned int objectId, parentObjectId, changeId, prevId, nextId;
unsigned short regionCode, areaCode, cityCode, placeCode, planCode, streetCode;
char updateDate[10], startDate[10], endDate[10];
bool isActive;
char path[300];
}
while (!feof(ah))
{
path = (struct Path*) malloc(sizeof(struct Path));
fscanf(ah, "%u %u %u %u %u %u %u %u %u %u %u %s %s %s %u %s",
&path->objectId, &path->parentObjectId, &path->changeId,
&path->regionCode, &path->areaCode, &path->cityCode, &path->placeCode, &path->planCode, &path->streetCode,
&path->prevId, &path->nextId,
&path->updateDate, &path->startDate, &path->endDate,
&path->isActive, &path->path);
free(path);
}
fclose(ah);