Infiole / jquery-csv

Automatically exported from code.google.com/p/jquery-csv
MIT License
0 stars 0 forks source link

import of CSV with only one column and no new line char at last line will omit the last entry #23

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Import a file with only one column and no new line character for last entry.

What is the expected output? What do you see instead?
Check for the last entry. It should be the last name in the file. It is 
currently showing second last name. The last name is not shown.

What version of the product are you using? On what operating system?
jquery.csv-0.7.1.js

Please provide any additional information below.

Original issue reported on code.google.com by vipul.sh...@manusis.com on 22 Jan 2013 at 7:45

Attachments:

GoogleCodeExporter commented 9 years ago
Really? Damn that's a tricky edge case.

I'll see what I can do.

Original comment by evanpla...@gmail.com on 25 Jan 2013 at 4:21

GoogleCodeExporter commented 9 years ago
One easy solution that worked for me is to add and remove a new line character 
before calling the CSV. 

Original comment by vipul.sh...@manusis.com on 25 Jan 2013 at 5:23

GoogleCodeExporter commented 9 years ago
I've found a fix without the need to append a 'end of line' char to the text 
input
but need some help from you to ensure it is not breaking any test case
my fix steps are:

1- add |$ to the match regexp, to be 
var match = /(D|S|\n|\r|[^DS\r\n]+)|$/;

2- in case 2 and case 3 inside the replace callback function, 
"endOfValue();break;" should also be called if the m0 is empty character
if (m0 === separator || m0 === "") {
    endOfValue();
    break;
}

----
kindly check attached file, I've implemented the fix in the 'parse' function

Original comment by AhmedMoz...@gmail.com on 5 Nov 2013 at 1:52

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by evanpla...@gmail.com on 9 Dec 2013 at 11:32