Comments (6)
Thanks for kind words!
This is indeed a bug. Should be fixed today.
from objectpath.
Fixed, when you have attribute name that begins with number, $, @ or other operator use:
$.'3h' notation.
from objectpath.
BTW, can I ask you what do you use OP for? I'm always curious:).
from objectpath.
Thanks for quick reply, now it works like a charm!
About your question: for my pet project I was looking for a way to store weather information from different forecast services (openweathermap.com, forecast.io, etc.) in a consistent form suitable for further analysis. As json format differs from service to service, I need a way to bring their data to common format.
May be you can help me with the following: can be transformation described below done by an ObjectPath query?
source = [{'dt': 1, 'rain':3}, {'dt':2, 'snow':5}]
dest = [{'time':1, 'precip_type':'rain', 'precip_intencity':3}, {'time':2, 'precip_type':'snow', 'precip_intencity':5}]
I came up with two queries solution: one to extract repeating block of data, second query(-es) to transform each block's values using Python dictionary which holds either ObjectPath query or Python function if i need extra logic:
repeating_block_query = '$.*'
transform_block_query = {'time': '$.dt',
'precip_type': get_precip_type,
'precip_intencity': get_precip_intencity}
Is there straight way to do it?
from objectpath.
Sure, but can you ask this on https://groups.google.com/forum/#!forum/objectpath or StackOverflow so that others could benefit from it? This issue is closed and not visible to anyone but us:).
from objectpath.
Ok, thanks!
from objectpath.
Related Issues (20)
- "key in $" no support for existence on root level HOT 2
- License clarification HOT 1
- Complience with Python 3.8 SyntaxWarning when comparing with a literal HOT 1
- objectpath.Tree(jsoncontent).execute('$.*') is raise error 'Syntax error' HOT 1
- date and time from string HOT 7
- Rethink the way ObjectPath **and** operator works
- Average Age of date objects HOT 2
- OpenWeatherMap JSON file is broken HOT 1
- ValueError: generator already executing HOT 1
- return full path
- Support for query by key using data from a list
- TypeError when calling tree.execute() HOT 2
- python3
- json_normalize usage HOT 1
- type check should use `isinstance` instead of `type() is` HOT 11
- Nested array query issue HOT 2
- Issue with attribute names consisting of a string with just a number inside? HOT 1
- pytz dependency missing in current pypi latest version (0.6.1) HOT 3
- no list of supported operators HOT 1
- Matching a string that includes single quote. HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from objectpath.