• Stars
    star
    1,829
  • Rank 25,381 (Top 0.6 %)
  • Language
    Python
  • License
    Other
  • Created over 6 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

☄️ Python's nested data operator (and CLI), for all your declarative restructuring needs. Got data? Glom it! ☄️

glom

Restructuring data, the Python way

Real applications have real data, and real data nests. Objects inside of objects inside of lists of objects.

glom is a new and powerful way to handle real-world data, featuring:

  • Path-based access for nested data structures
  • Readable, meaningful error messages
  • Declarative data transformation, using lightweight, Pythonic specifications
  • Built-in data exploration and debugging features

All of that and more, available as a fully-documented, pure-Python package, tested on Python 3.7+, as well as PyPy3. Installation is as easy as:

  pip install glom

And when you install glom, you also get the glom command-line interface, letting you experiment at the console, but never limiting you to shell scripts:

Usage: glom [FLAGS] [spec [target]]

Command-line interface to the glom library, providing nested data access and data
restructuring with the power of Python.

Flags:

  --help / -h                     show this help message and exit
  --target-file TARGET_FILE       path to target data source (optional)
  --target-format TARGET_FORMAT   format of the source data (json or python) (defaults
                                  to 'json')
  --spec-file SPEC_FILE           path to glom spec definition (optional)
  --spec-format SPEC_FORMAT       format of the glom spec definition (json, python,
                                  python-full) (defaults to 'python')
  --indent INDENT                 number of spaces to indent the result, 0 to disable
                                  pretty-printing (defaults to 2)
  --debug                         interactively debug any errors that come up
  --inspect                       interactively explore the data

Anything you can do at the command line readily translates to Python code, so you've always got a path forward when complexity starts to ramp up.

Examples

Without glom

>>> data = {'a': {'b': {'c': 'd'}}}
>>> data['a']['b']['c']
'd'
>>> data2 = {'a': {'b': None}}
>>> data2['a']['b']['c']
Traceback (most recent call last):
...
TypeError: 'NoneType' object is not subscriptable

With glom

>>> glom(data, 'a.b.c')
'd'
>>> glom(data2, 'a.b.c')
Traceback (most recent call last):
...
PathAccessError: could not access 'c', index 2 in path Path('a', 'b', 'c'), got error: ...

Learn more

If all this seems interesting, continue exploring glom below:

All of the links above are overflowing with examples, but should you find anything about the docs, or glom itself, lacking, please submit an issue!

In the meantime, just remember: When you've got nested data, glom it! ☄️

More Repositories

1

awesome-python-applications

💿 Free software that works great, and also happens to be open-source Python.
Jupyter Notebook
16,672
star
2

boltons

🔩 Like builtins, but boltons. 250+ constructs, recipes, and snippets which extend (and rely on nothing but) the Python standard library. Nothing like Michael Bolton.
Python
6,473
star
3

calver

📅 The web's go-to resource for Calendar Versioning info.
CSS
438
star
4

zerover

0️⃣ Minimalist versioning scheme for devs who can't be bothered.
CSS
168
star
5

clastic

🏔️ A functional web framework that streamlines explicit development practices while eliminating global state.
Python
155
star
6

lithoxyl

Application instrumentation and logging, with a geological bent.
Python
144
star
7

ashes

⚱️ Lightweight, self-contained templating for Python 2 and 3, a la Dust templates
Python
56
star
8

espymetrics

EspyMetrics is a pure-Python analytics service that tracks Python usage. It is the reference project for Enterprise Software with Python.
Python
51
star
9

wapiti

Wikipedia API wrapper for humans and elk. (en.wikipedia.org/w/api.php, get it?)
Python
36
star
10

apatite

Awesomer awesome list management and analysis, originally designed for Awesome Python Applications: https://github.com/mahmoud/awesome-python-applications
Python
36
star
11

skeleton_sticky_footer

A minimally-enhanced version of the Skeleton 2.0.4 basic example with a sticky footer.
CSS
24
star
12

chert

Sharp and sparky static site generation.
Python
22
star
13

face

🗿 Straightforward CLI parsing and dispatching microframework
Python
21
star
14

glompad

JavaScript
6
star
15

ipynb-ftw

IPython notebooks automatically pulled from my server.
Python
6
star
16

strata

Multi-dimensional, topologically-driven, dependency-resolving configuration framework, built to handle the complexities of advanced projects.
Python
5
star
17

hematite

Cold, hard HTTP.
Python
4
star
18

etavta

A web tool and command line utility to make sense of VTA (http://www.vta.org/) Light Rail schedules.
Python
4
star
19

PythonDoesWhat

A repo for all the adventures on http://pythondoeswhat.blogspot.com
Python
4
star
20

PythonDoesBlog

A Python-centric static blog generator
Python
4
star
21

sedimental

The personal website of Mahmoud Hashemi. Mental sediments, sedimentary and sentimental.
CSS
3
star
22

less-css-mode

An emacs major mode for editing LESS (the better CSS)
Emacs Lisp
3
star
23

womp

womp (Wikipedia Open Metrics Platform) is a data extraction, processing, and management suite.
Python
3
star
24

euler

a few solutions here and there
Python
2
star
25

picritic

Python Package Index surveyor
Python
2
star
26

briefings

a throwaway bit of stuff for whitehouse press briefings for the internet archive govt data hackathon 2017
Python
2
star
27

diffusion

delta force
Python
2
star
28

grumblr

a little maintenance utility for tumblr blogs
Python
2
star
29

Programming-Problem-Solutions

These solutions are new and old and were written under time pressure to get a solution done quickly. Many of the questions were sourced from hacker rank
Python
2
star
30

talks

various talks, presentations, and proposals
1
star
31

socklusion

Simple, parallel, isolated, cross-platform socket interface for fire-and-forget messages.
Python
1
star
32

radio_commons

a (potentially temporary) repo for a commons radio
Python
1
star
33

misc_docs

papers just papers
1
star
34

words

those dreaded nemeses of actions
1
star
35

hatnote

Oh, y'know, some Wikipedia thoughts.
1
star
36

erosion

Exogenic linkrot for limited sharing. An example application for Clastic, Strata, and Lithoxyl.
Python
1
star
37

catamaran

Automatic categorization for MediaWiki
1
star