jpace121 / jquery-csv

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

String parse error #21

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. when try to parse string receive error

String:
"School", "1601-1643 E Pythian St", "Dallas", "TX", "22334", 32.838058, 
-97.017517

Error: Uncaught Error: CSVDataError: Illegal Quote [Row:1][Col:2]

Tested in Chrome
When remove [space] after , and string become
"School","1601-1643 E Pythian St","Dallas","TX","22334",32.838058,-97.017517
then plugin work how expected

Original issue reported on code.google.com by duca14...@gmail.com on 25 Dec 2012 at 3:55

GoogleCodeExporter commented 9 years ago
Not surprising, your input contains illegal data.

According to the CSV spec, whitespace contained outside of a proper delimiter 
is considered illegal. Come to think of it, I could probably improve the error 
handling to explain as much.

**So for:**

"School", "1601-1643 E Pythian St"

**The space denoted by # is causing your issue:**

"School",#"1601-1643 E Pythian St"

*Note: The error clearly explains the issue. The first illegal instance is 
found in the second value of the first row.*

It's an easy fix by hand but if you have a large data set with 'whitespace 
issues' it might be easher/quicker to write a preprocessor to handle the 
cleanup. 

If that's what you need, let me know and I'll consider it as a new feature 
request. I doubt you'll be the last person who has this issue so it's within 
the best interest of the project to provide a solution.

If you'd like to write one yourself I can help too. I need to first add the 
preParse() callbacks but the rest can be handled by a single hook function. In 
fact, it shouldn't take a lot of effort to adapt the $.csv.parsers.splitLines() 
to accomplish what you're asking.

Let me know the approach you'd like to take.

Original comment by evanpla...@gmail.com on 27 Dec 2012 at 7:34

GoogleCodeExporter commented 9 years ago
I know that [space] create problems, but we know that if column contain [space] 
he will be wrapped with "" this mean that ',[space]' or '[space],' also must be 
accepted as delimiter and in my case are very easy to fix this. otherwise let 
consider it as a new feature request. I like it and don't have any pretensions.

Original comment by duca14...@gmail.com on 27 Dec 2012 at 2:58

GoogleCodeExporter commented 9 years ago
Consider this an accepted feature request.

I'm not exactly sure how to merge issues but you can follow the development on 
Issue 22.

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