Skip to main content

Pluck and flatten complex data.

Project description

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

cherrypicker provides a chainable filter and extraction interface to allow you to easily pick out objects from complex structures and place them in a flat table. It fills a similar role to jQuery in JavaScript, enabling you to navigate complex structures without the need for lots of complex nested for loops or list comprehensions.

Examples

>>> 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cherrypicker-0.4.0.tar.gz (221.6 kB view details)

Uploaded Source

File details

Details for the file cherrypicker-0.4.0.tar.gz.

File metadata

  • Download URL: cherrypicker-0.4.0.tar.gz
  • Upload date:
  • Size: 221.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.8

File hashes

Hashes for cherrypicker-0.4.0.tar.gz
Algorithm Hash digest
SHA256 dac52a21eba5dcb2d568a1a787bc8e1d731f76104af1eb2bfca0c55a9b3abf26
MD5 88a43291a8cbe5ca8c30dfebeeb79a3b
BLAKE2b-256 f2c637c2fa453de028a8df33e6ce6c55b42b3bbf1bc42e5fa7bdcfb63052063a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page