Trim newlines from csv data

If the newline happens in the middle some field, replace it with a space.
We can't import newlines in gnucash.
This commit is contained in:
Geert Janssens 2017-02-11 11:13:39 +01:00
parent 9fbbd7366c
commit 4687eb649b

View File

@ -9,6 +9,7 @@
#include <boost/tokenizer.hpp>
#include <boost/locale.hpp>
#include <boost/algorithm/string.hpp>
void
GncCsvTokenizer::set_separators(const std::string& separators)
@ -36,6 +37,7 @@ int GncCsvTokenizer::tokenize()
while (std::getline (in_stream, buffer))
{
// --- deal with line breaks in quoted strings
buffer = boost::trim_copy (buffer); // Removes trailing newline and spaces
last_quote = buffer.find_first_of('"');
while (last_quote != std::string::npos)
{
@ -50,7 +52,7 @@ int GncCsvTokenizer::tokenize()
line.append(buffer);
if (inside_quotes)
{
line.append("\n");
line.append(" ");
continue;
}
// ---