contadorafa / jquery-csv

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

$.csv.parsers.splitLines(csv) does not work #26

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Returns:

Uncaught TypeError: Cannot read property 'separator' of undefined 
jquery.csv-0.71.min.js:27
$.csv.parsers.splitLines jquery.csv-0.71.min.js:27

When I add the optional configuration {separator: "," , delimiter: "\x22" } the 
console returns:

Uncaught TypeError: Cannot read property 'rowNum' of undefined 
jquery.csv-0.71.min.js:27
$.csv.parsers.splitLines jquery.csv-0.71.min.js:27

Original issue reported on code.google.com by dirk.ste...@wondergraphs.com on 7 Apr 2013 at 6:09

GoogleCodeExporter commented 9 years ago
Checked the source and it's a simple problem of an empty options.state object.

Line 278: if(!options.state.rowNum)

When I pass in an option like this it works:
var splitLines = $.csv.parsers.splitLines(t, {separator: ",", delimiter: 
"\x22", state: { } });

Original comment by dirk.ste...@wondergraphs.com on 7 Apr 2013 at 6:20

GoogleCodeExporter commented 9 years ago
I'll take a look at it.

I added more state tracking on the last update and probably just missed the 
default state object creation on the splitLines method.

Thank you for the feedback.

Original comment by evanpla...@gmail.com on 8 Apr 2013 at 4:25

GoogleCodeExporter commented 9 years ago
If you want a quick and dirty fix. Just add a 'state' object literal with 
rowNum and colNum both initialized to 0.

To see what I mean, just take a look at some of the other functions. The proper 
fix would be to make splitLines so it inherits its state from the function 
arguments with defaults as a fallback.

Original comment by evanpla...@gmail.com on 23 Apr 2013 at 12:59

GoogleCodeExporter commented 9 years ago

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