Coder Social home page Coder Social logo

Comments (6)

mrodrig avatar mrodrig commented on July 18, 2024

By escaped, you mean adding a '' in front of the delimiter right? It's something I hadn't considered yet - I just figured that the delimiter would be changed, but if someone doesn't want to change the delimiter it is a nice feature. I'll definitely take a look at implementing this.

from json-2-csv.

pgilad avatar pgilad commented on July 18, 2024

Perhaps this could be of help, they quote elements that contain the delimiter:
https://github.com/mholt/PapaParse/blob/master/papaparse.js#L241-L389

from json-2-csv.

dillten avatar dillten commented on July 18, 2024

@pgilad are you saying the source data looks like:

{ "key,field": "value,field" }

and you're thinking it should parse to "key,field","value,field"?

Can you provide a test case?

from json-2-csv.

pgilad avatar pgilad commented on July 18, 2024

let's assume that you have a value that holds a description or note of some kind, it might be:

//...
{ description: "Clicking this you will activate Panyo, which is a very long commented text..." }
//...

This fails if it will not be quoted. Same goes for keys

thinking again I might be wrong, since you are parsing JSON the keys/values must be quoted, so it depends if the CSV always outputs quoted elements

from json-2-csv.

dillten avatar dillten commented on July 18, 2024

If the delimiter.field (comma) is included in a json input string and no options are specified, then yes, the output string will be incorrect. The fix would be to specify a delimiter.wrap option (typically \") to wrap all the output strings, or alternatively change the output delimiter (perhaps tab or semicolon).

I added a test to cover this condition in the wrapped output, but not sure how one would want to handle scanning a document for a conflict of this type (document contains strings that match field character with no wrap option specified) ahead of conversion.

from json-2-csv.

mrodrig avatar mrodrig commented on July 18, 2024

Thanks for adding the test. The standard seems to be adding the wrap delimiter as @dillten mentioned.

from json-2-csv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.