detect lines with blank fields only

This commit is contained in:
john30
2016-01-30 17:35:37 +01:00
parent 88d3086a6d
commit d6aab00335
+5 -2
View File
@@ -119,8 +119,7 @@ public:
vector< vector<string> > defaults; vector< vector<string> > defaults;
while (getline(ifs, line) != 0) { while (getline(ifs, line) != 0) {
lineNo++; lineNo++;
splitFields(line, row); if (!splitFields(line, row) || row.empty())
if (row.empty())
continue; continue;
result_t result; result_t result;
@@ -244,6 +243,7 @@ public:
bool quotedText = false, wasQuoted = false; bool quotedText = false, wasQuoted = false;
ostringstream field; ostringstream field;
char prev = FIELD_SEPARATOR; char prev = FIELD_SEPARATOR;
bool empty = true;
for (size_t pos = 0; pos < length; pos++) { for (size_t pos = 0; pos < length; pos++) {
char ch = line[pos]; char ch = line[pos];
switch (ch) switch (ch)
@@ -254,6 +254,7 @@ public:
} else { } else {
string str = field.str(); string str = field.str();
trim(str); trim(str);
empty &= str.empty();
row.push_back(str); row.push_back(str);
field.str(""); field.str("");
wasQuoted = false; wasQuoted = false;
@@ -285,6 +286,8 @@ public:
} }
string str = field.str(); string str = field.str();
trim(str); trim(str);
if (empty && str.empty())
return false;
row.push_back(str); row.push_back(str);
return true; return true;
} }