leixiangwu / csv-parser-cplusplus

Automatically exported from code.google.com/p/csv-parser-cplusplus
GNU General Public License v3.0
0 stars 0 forks source link

Wrong parsing with comma inside a textfield #7

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. With this line the result is correct:

"16644","TP-Link Antenna Extension Cable 
TL-ANT24EC5S","Antenne","6935364052058","TL-ANT24EC5S","TP-Link",7.20,"0",""

COLUMN 01 : 16644
COLUMN 02 : TP-Link Antenna Extension Cable TL-ANT24EC5S
COLUMN 03 : Antenne
COLUMN 04 : 6935364052058
COLUMN 05 : TL-ANT24EC5S
COLUMN 06 : TP-Link
COLUMN 07 : 7.20
COLUMN 08 : 0
COLUMN 09 : "
====================================================================
END OF ROW 04
====================================================================

2. With htis line, the result is NOT correct bc the comma in '2,4GHz':

"15844","TP-Link Antenne 5dBi Indoor Omni-dircetional 2,4GHz 
TL-ANT2405C","Antenne","6935364052010","TL-ANT2405C","TP-Link",3.60,"11",""

COLUMN 01 : 15844
COLUMN 02 : TP-Link Antenne 5dBi Indoor Omni-dircetional 2,
COLUMN 03 : 4GHz TL-ANT2405
COLUMN 04 : Antenne
COLUMN 05 : 6935364052010
COLUMN 06 : TL-ANT2405C
COLUMN 07 : TP-Link
COLUMN 08 : 3.60
COLUMN 09 : 11
COLUMN 10 : "
====================================================================
END OF ROW 05
====================================================================

What is the expected output? What do you see instead?
The correct result would be an output of 9 elements instead of 10.

What version of the product are you using? On what operating system?
Version is 1.0, tested with Fedora 19, Ubunti 11.10, Ubuntu 10.x

Please provide any additional information below.
I liej the idea of csv-parser, but I think, there is a little bit lack of 
maintenance ;-)

Original issue reported on code.google.com by gboel...@gmail.com on 4 Feb 2012 at 7:11

GoogleCodeExporter commented 8 years ago
The function _get_fields_with_optional_enclosure has a bug. It needs the 
following:

if (curr_char == enclosed_char) {
    bInEscape = !bInEscape;
}

if (curr_char == field_term_char && !bInEscape) {
    field_end = char_pos;
    ...

Original comment by boba...@gmail.com on 15 Apr 2012 at 11:39

Attachments: