mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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:
parent
9fbbd7366c
commit
4687eb649b
@ -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;
|
||||
}
|
||||
// ---
|
||||
|
Loading…
Reference in New Issue
Block a user