Pluck and flatten complex data.
Flatten complex data.
cherrypicker aims to make common ETL tasks (filtering data and restructuring it into flat tables) easier, by taking inspiration from jQuery and applying it in a Pythonic way to generic data objects.
pip install cherrypicker
>>> from cherrypicker import CherryPicker >>> import json >>> with open('climate.json', 'r') as fp: ... data = json.load(fp) >>> picker = CherryPicker(data)
>>> picker['id', 'city'].get() [[1, 'Amsterdam'], [2, 'Athens'], [3, 'Atlanta GA'], ...]
>>> picker(city='B*')['info']( ... population=lambda n: n > 2000000, ... area=lambda a: a < 2000 ... )['area', 'population'].get() [[1568, 8300000], [891, 3700000], [203, 2800000]]
More complex filtering and flattening of nested structures is possible. Learn more in the documentation: https://cherrypicker.readthedocs.io.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.