-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Basic JSON normalization/flattening #4007
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
Conversation
@nehalecky can i get some feedback? |
@wesm, hey! Yes, I will roll this out to a direct use case I have and let you know. I was hoping to do so today, so I'll get back soon. ty. |
Really busy yesterday, I am going to try and get to this today. :) |
@nehalecky did you get a chance to try out? we adding this to 0.12? |
Hey @jreback. I am finishing one last deadline (due today). My very next project will benefit much from this functionality, so I will be testing it out. I have a deadline for this early next week, and will certainly have reviewed this by then. If that works, great and either way I will let you know my thoughts. :) THANKS! |
maybe push to 0.13? @wesm? |
yes let's push to 0.13 so it can see some work |
Warning: cute. def jqj(data,rule):
from sh import jq
from sh import ErrorReturnCode
import json
jq = jq.bake('-M')
try:
return json.loads(jq(rule,_in=json.dumps(data)).stdout)
except ErrorReturnCode as e:
raise RuntimeError("Jq exited with an error\n%s" % str(e))
data = dict(dwarves={'names':['dancer','prancer','grinch']},tale='rambo II')
rule = '[{name: .dwarves.names[],tale}]'
jqj(data,rule)
[{u'name': u'dancer', u'tale': u'rambo II'},
{u'name': u'prancer', u'tale': u'rambo II'},
{u'name': u'grinch', u'tale': u'rambo II'}] |
That's pretty nifty |
@nehalecky @cpcloud @wesm try to merge to 0.13? |
@nehalecky have a look? |
@wesm, merge this? |
Sure, it's good to go by me. |
ok..let me rebase....and can do |
…ttening nested records per #1067
CLN: py3 updates
Basic JSON normalization/flattening
Sorry all, life + work is all really busy. In startup's requirements change quickly! Regarding the PR, glad to see it's been merged and included in Thank for all your efforts! |
@nehalecky gr8...try it out....it may not be super fast....(optimization PR's always welcome)...b.ut should be good on moderately sized sets |
xref: http://stackoverflow.com/questions/21494030/create-a-pandas-dataframe-from-deeply-nested-json @y-p thanks for that snippet above |
I've looked at this again recently for other reasons and found plenty of existing, If you're interested google: jaql, jsonpath, jsoniq or jsont. Appreciate your care for attribution. |
closes #1067.
This isn't a fast function but has quite a bit of functionality. Take a look at the unit tests. Comments on the API welcome and this could use a few iterations. Various ad hoc things like concatenating "key paths" to metadata