Skip to content

Commit

Permalink
Improved error checking, updated CSV parser
Browse files Browse the repository at this point in the history
The CSV-parser update fixes a bug that would've occured with some input files, in particular if they were touched by a third party tool like LibreOffice
  • Loading branch information
SydMontague committed Mar 3, 2020
1 parent 53d4125 commit c88f678
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions DSCSTools/EXPA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,13 @@ void packMBE(boost::filesystem::path source, boost::filesystem::path target) {
bool first = true;

for (auto &row : parser) {
if (first) {
if (localFormat.size() != row.size()) {
std::cout << "Error: structure element count differs from input element count. The wrong structure may be used?" << std::endl;
std::cout << "Expected: " << localFormat.size() << " | Found: " << row.size() << std::endl;
return;
}
if (localFormat.size() != row.size()) {
std::cout << "Error: structure element count differs from input element count. The wrong structure may be used?" << std::endl;
std::cout << "Expected: " << localFormat.size() << " | Found: " << row.size() << std::endl;
return;
}

if (first) {
first = false;
continue;
}
Expand Down
3 changes: 2 additions & 1 deletion libs/csv-parser/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ namespace aria {
m_cursor++;
if (c == m_terminator) {
handle_crlf(c);
return Field(FieldType::ROW_END);
m_state = State::END_OF_ROW;
return Field(m_fieldbuf);
}

if (c == m_quote) {
Expand Down

0 comments on commit c88f678

Please sign in to comment.