Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement ideas! #16

Closed
bsantosh909 opened this issue Dec 11, 2020 · 3 comments
Closed

Improvement ideas! #16

bsantosh909 opened this issue Dec 11, 2020 · 3 comments

Comments

@bsantosh909
Copy link

I was using this package for one of my project and recently got to know about some limitations and bugs in the package:

  1. Boolean type is not parsed. I even submitted a PR, but later realized it was not working as intended
  2. Number parsers is not accurate. Empty string will also be parsed as number and results to 0
  3. Better identification for delimiter is required.
    if I have a field ,"how are you, I hope you are doing fine",0
    here the , inside the quotation is still regarded as delimiter.. so I guess Support for quoted strings is needed

Hope to see these changes happening..

iuccio pushed a commit that referenced this issue Dec 13, 2020
iuccio pushed a commit that referenced this issue Dec 16, 2020
@iuccio
Copy link
Owner

iuccio commented Dec 16, 2020

@TheLearneer

the 1. and 2. points are now correctly implemented with the release v1.0.2

About the 3. point:
to be able to get the entire sentence, that includes the comma, you just need to change the field delimiter of your csv file. For example you can use the semi column (;) as field delimiter. After that in your source code, you have to use the following call (see Define field delimiter):

csvToJson.fieldDelimiter(';').getJsonFromCsv(yourFile);

@iuccio iuccio closed this as completed Dec 16, 2020
@aataylor
Copy link

aataylor commented Dec 18, 2020

I came up against the issue 3 reported here as well and found a way around it. Looking at the source, it's doing split() using the delimiter you pass in. Because of that, it's possible to specify regex as the delimiter and it works for my purposes. Perhaps that will for yours too.

Regex I found on the internet: ,(?=(?:[^"]*"[^"]*")*[^"]*$)

image

using it with csvToJson:
csvToJson.fieldDelimiter(/,(?=(?:[^"]*"[^"]*")*[^"]*$)/).getJsonFromCsv(file);

@roberrrt-s
Copy link

@aataylor This works perfectly, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants