-
Notifications
You must be signed in to change notification settings - Fork 14
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
CSV #79
Comments
I think this is a reasonable addition, given the existence of a good Go CSV library. Suggestions welcome! |
converting csv->json should be a no brainer, while the opposite is not because csv only supports a flat schema. Using the dot notation seem the most common solution for nested records:
Btw since this is rarely used i think you could just make the conversion fail in this case. |
Encoding is indeed a huge pain. It may be best if you just start with decoding only. When I tried to implement this and I found it to be a pain because you have to basically decide how to handle non-arrays and arrays of non-homogenous objects. It's probably okay to simply fail in many cases, but limits the usefulness quite a bit. For decoding, you'll also need to think about the following:
|
An array of objects should be nicer.
you can omit the fields in the objects or leave them as empty strings. e.g. you have this csv:
This is the
Alternative with omitted missing fields:
|
I wasn't talking about values missing, but headers. Eg:
|
catmandu just assume the first row is always the header.
Another command that is able to convert
With the headers i get this, which looks a bit confusing to me:
|
I think the 2nd output is more what I was describing. I don't think it's wise to assume every file has headers, hence the point I was trying to make about having decoder specific options to control this kind of behavior. It's probably fine to start with assuming headers are set. Someone can add headers like this:
|
With separators auto-guessing and optional overrides:
https://en.wikipedia.org/wiki/Comma-separated_values
faq -f json -o csv < file.json
The text was updated successfully, but these errors were encountered: