From 1f2fe401f1e98a9a1d3122b79593e12a668bfb43 Mon Sep 17 00:00:00 2001 From: Johann Klähn Date: Sat, 13 Oct 2012 19:38:42 +0200 Subject: ignore (some) empty field when converting csv This fixes bug #733 and bug #734. --- src/csv.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/csv.cc') diff --git a/src/csv.cc b/src/csv.cc index 71b6516a..aca69307 100644 --- a/src/csv.cc +++ b/src/csv.cc @@ -175,7 +175,8 @@ xact_t * csv_reader::read_xact(bool rich_data) break; case FIELD_DATE_AUX: - xact->_date_aux = parse_date(field); + if (! field.empty()) + xact->_date_aux = parse_date(field); break; case FIELD_CODE: @@ -224,7 +225,8 @@ xact_t * csv_reader::read_xact(bool rich_data) break; case FIELD_NOTE: - xact->note = field; + if (! field.empty()) + xact->note = field; break; case FIELD_UNKNOWN: -- cgit v1.2.3 From 937c9c7bd1a96ca24ecae71695f12bd25641c14c Mon Sep 17 00:00:00 2001 From: Johann Klähn Date: Sat, 13 Oct 2012 20:03:44 +0200 Subject: ignore extra fields when converting csv files This fixes bug #736. --- src/csv.cc | 2 +- test/regress/68917252.dat | 2 ++ test/regress/68917252.test | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 test/regress/68917252.dat create mode 100644 test/regress/68917252.test (limited to 'src/csv.cc') diff --git a/src/csv.cc b/src/csv.cc index aca69307..4992372a 100644 --- a/src/csv.cc +++ b/src/csv.cc @@ -166,7 +166,7 @@ xact_t * csv_reader::read_xact(bool rich_data) string total; string field; - while (instr.good() && ! instr.eof()) { + while (instr.good() && ! instr.eof() && n < index.size()) { field = read_field(instr); switch (index[n]) { diff --git a/test/regress/68917252.dat b/test/regress/68917252.dat new file mode 100644 index 00000000..8857f741 --- /dev/null +++ b/test/regress/68917252.dat @@ -0,0 +1,2 @@ +date,amount, +12/12/2011,10,test,extra,fields diff --git a/test/regress/68917252.test b/test/regress/68917252.test new file mode 100644 index 00000000..52fde1d9 --- /dev/null +++ b/test/regress/68917252.test @@ -0,0 +1,5 @@ +test -f /dev/null --input-date-format "%m/%d/%Y" convert test/regress/68917252.dat +2011/12/12 * + Expenses:Unknown 10 + Equity:Unknown +end test -- cgit v1.2.3