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

Values from json array to seperate csv fields #17

Open
RoelandSteur opened this issue Sep 24, 2013 · 1 comment
Open

Values from json array to seperate csv fields #17

RoelandSteur opened this issue Sep 24, 2013 · 1 comment

Comments

@RoelandSteur
Copy link

I love this tool! I'm using it to convert json files from Twitter's streaming API to csv. I have very little programming skills, so this tool is really good for me.

However I'm stuck at this point where I would like to extract values from the coordinate pairs within tweets. I think the coordinates are stored as an array:

"coordinates": {"coordinates": [3.82955502, 51.48484907], "type": "Point"}

Would it be possible to store the X and Y-coordinate in a separate csv field?

I tried: "json2csv -k coordinates.coordinates[0],coordinates.coordinates[1] -i ...etc" but this doesn't work.

Thanks in advance!
Roeland

@jehiah
Copy link
Owner

jehiah commented Sep 24, 2013

@RoelandSteur This is a great idea, and it's a feature set i hope json2csv grows to encompass.

There is another tool jq that has some more advanced json reformatting capabilities. You should be able to combine them to accomplish what you are looking for.

echo '{"coordinates": [3.82955502, 51.48484907], "type": "Point"}' | jq -c '{x:.coordinates[0],y:.coordinates[1]}' | json2csv -k x,y
3.829555,51.484849

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

2 participants