-
Notifications
You must be signed in to change notification settings - Fork 0
/
csvTest.cpp
40 lines (39 loc) · 1.01 KB
/
csvTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "csvParser.h"
#include <stdio.h>
#include <unistd.h>
int main(int argc, char **argv) {
if (argc < 2) {
return 1;
}
auto csvClass = CsvClass();
bool ok = csvClass.ReadCsv(argv[argc - 1], ',');
uint32_t nRows = csvClass.NumRows();
uint32_t nCols = csvClass.NumCols();
printf("Read ok %d Rows %u max columns %u\n", ok, nRows, nCols);
for (uint32_t r = 0; r < nRows; r++) {
for (uint32_t c = 0; c < nCols; c++) {
CsvCellType cell = csvClass.GetCell(r, c);
switch (cell.status) {
case missingRow:
case missingCol:
break;
case emptyCell:
if (cell.lastCellInRow == false)
printf(",");
break;
case normalCell:
if (cell.bytes == 0) {
printf("->Zero bytes for a normal Cell<-");
}
printf("%s", cell.cellContents);
if (cell.lastCellInRow == false)
printf(",");
break;
default:
printf("->WTF? %d <-", (int)cell.status);
break;
}
}
printf("\n");
}
}