# glom
*Restructuring data, the Python way*
<a href="https://pypi.org/project/glom/"><img src="https://img.shields.io/pypi/v/glom.svg"></a>
<a href="https://calver.org/"><img src="https://img.shields.io/badge/calver-YY.MM.MICRO-22bfda.svg"></a>
<img width="30%" align="right" src="https://raw.githubusercontent.com/mahmoud/glom/master/docs/_static/comet.png">
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][rtd],
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][cli_rtd], 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, python, toml,
or yaml) (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
```python
>>> 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
```python
>>> 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
<img width="30%" align="right" src="https://raw.githubusercontent.com/mahmoud/glom/master/docs/_static/comet_multi.png">
If all this seems interesting, continue exploring glom below:
* [glom Tutorial][tutorial]
* [Full API documentation at Read the Docs][rtd]
* [Original announcement blog post (2018-05-09)][glom_announce]
* [Frequently Asked Questions][faq]
* [PyCon 2018 Lightning Talk (2018-05-11)][pycon_talk]
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][gh_issues]!
[rtd]: https://glom.readthedocs.io
[cli_rtd]: http://glom.readthedocs.io/en/latest/cli.html
[tutorial]: https://glom.readthedocs.io/en/latest/tutorial.html
[faq]: https://glom.readthedocs.io/en/latest/faq.html
[glom_announce]: https://sedimental.org/glom_restructured_data.html
[gh_issues]: https://github.com/mahmoud/glom/issues/
[pycon_talk]: https://www.youtube.com/watch?v=bTAFl8P2DkE&t=18m07s
In the meantime, just remember: When you've got nested data, glom it! ☄️
Raw data
{
"_id": null,
"home_page": "https://github.com/mahmoud/glom",
"name": "glom",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Mahmoud Hashemi and Kurt Rose",
"author_email": "mahmoud@hatnote.com",
"download_url": "https://files.pythonhosted.org/packages/05/89/b57cfbc448189426f2e01b244fbe9226b059ef5423a9d49c1d335a1f1026/glom-24.11.0.tar.gz",
"platform": "any",
"description": "# glom\n\n*Restructuring data, the Python way*\n\n<a href=\"https://pypi.org/project/glom/\"><img src=\"https://img.shields.io/pypi/v/glom.svg\"></a>\n<a href=\"https://calver.org/\"><img src=\"https://img.shields.io/badge/calver-YY.MM.MICRO-22bfda.svg\"></a>\n\n<img width=\"30%\" align=\"right\" src=\"https://raw.githubusercontent.com/mahmoud/glom/master/docs/_static/comet.png\">\n\nReal applications have real data, and real data nests. Objects inside\nof objects inside of lists of objects.\n\nglom is a new and powerful way to handle real-world data, featuring:\n\n* Path-based access for nested data structures\n* Readable, meaningful error messages\n* Declarative data transformation, using lightweight, Pythonic specifications\n* Built-in data exploration and debugging features\n\nAll of that and more, available as a [fully-documented][rtd],\npure-Python package, tested on Python 3.7+, as well as\nPyPy3. Installation is as easy as:\n\n```\n pip install glom\n```\n\nAnd when you install glom, you also get [the `glom` command-line\ninterface][cli_rtd], letting you experiment at the console, but never limiting\nyou to shell scripts:\n\n```\nUsage: glom [FLAGS] [spec [target]]\n\nCommand-line interface to the glom library, providing nested data access and data\nrestructuring with the power of Python.\n\nFlags:\n\n --help / -h show this help message and exit\n --target-file TARGET_FILE path to target data source (optional)\n --target-format TARGET_FORMAT\n format of the source data (json, python, toml,\n or yaml) (defaults to 'json')\n --spec-file SPEC_FILE path to glom spec definition (optional)\n --spec-format SPEC_FORMAT format of the glom spec definition (json, python,\n python-full) (defaults to 'python')\n --indent INDENT number of spaces to indent the result, 0 to disable\n pretty-printing (defaults to 2)\n --debug interactively debug any errors that come up\n --inspect interactively explore the data\n\n```\n\nAnything you can do at the command line readily translates to Python\ncode, so you've always got a path forward when complexity starts to\nramp up.\n\n\n## Examples\n#### Without glom\n```python\n>>> data = {'a': {'b': {'c': 'd'}}}\n>>> data['a']['b']['c']\n'd'\n>>> data2 = {'a': {'b': None}}\n>>> data2['a']['b']['c']\nTraceback (most recent call last):\n...\nTypeError: 'NoneType' object is not subscriptable\n```\n\n#### With glom\n```python\n>>> glom(data, 'a.b.c')\n'd'\n>>> glom(data2, 'a.b.c')\nTraceback (most recent call last):\n...\nPathAccessError: could not access 'c', index 2 in path Path('a', 'b', 'c'), got error: ...\n```\n\n## Learn more\n\n<img width=\"30%\" align=\"right\" src=\"https://raw.githubusercontent.com/mahmoud/glom/master/docs/_static/comet_multi.png\">\n\nIf all this seems interesting, continue exploring glom below:\n\n* [glom Tutorial][tutorial]\n* [Full API documentation at Read the Docs][rtd]\n* [Original announcement blog post (2018-05-09)][glom_announce]\n* [Frequently Asked Questions][faq]\n* [PyCon 2018 Lightning Talk (2018-05-11)][pycon_talk]\n\nAll of the links above are overflowing with examples, but should you\nfind anything about the docs, or glom itself, lacking, [please submit\nan issue][gh_issues]!\n\n[rtd]: https://glom.readthedocs.io\n[cli_rtd]: http://glom.readthedocs.io/en/latest/cli.html\n[tutorial]: https://glom.readthedocs.io/en/latest/tutorial.html\n[faq]: https://glom.readthedocs.io/en/latest/faq.html\n[glom_announce]: https://sedimental.org/glom_restructured_data.html\n[gh_issues]: https://github.com/mahmoud/glom/issues/\n[pycon_talk]: https://www.youtube.com/watch?v=bTAFl8P2DkE&t=18m07s\n\nIn the meantime, just remember: When you've got nested data, glom it! \u2604\ufe0f\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "A declarative object transformer and formatter, for conglomerating nested data.",
"version": "24.11.0",
"project_urls": {
"Documentation": "https://glom.readthedocs.io/en/latest/",
"Homepage": "https://github.com/mahmoud/glom"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9ca275fd80784ec33da8d39cf885e8811a4fbc045a90db5e336b8e345e66dbb2",
"md5": "d727631f0a6ca759c2c99f71dd6a7371",
"sha256": "991db7fcb4bfa9687010aa519b7b541bbe21111e70e58fdd2d7e34bbaa2c1fbd"
},
"downloads": -1,
"filename": "glom-24.11.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d727631f0a6ca759c2c99f71dd6a7371",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 102690,
"upload_time": "2024-11-02T23:17:46",
"upload_time_iso_8601": "2024-11-02T23:17:46.468685Z",
"url": "https://files.pythonhosted.org/packages/9c/a2/75fd80784ec33da8d39cf885e8811a4fbc045a90db5e336b8e345e66dbb2/glom-24.11.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0589b57cfbc448189426f2e01b244fbe9226b059ef5423a9d49c1d335a1f1026",
"md5": "dcf7caca78f3dc77a17af6cbe29cc2a9",
"sha256": "4325f96759a912044af7b6c6bd0dba44ad8c1eb6038aab057329661d2021bb27"
},
"downloads": -1,
"filename": "glom-24.11.0.tar.gz",
"has_sig": false,
"md5_digest": "dcf7caca78f3dc77a17af6cbe29cc2a9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 195120,
"upload_time": "2024-11-02T23:17:50",
"upload_time_iso_8601": "2024-11-02T23:17:50.405311Z",
"url": "https://files.pythonhosted.org/packages/05/89/b57cfbc448189426f2e01b244fbe9226b059ef5423a9d49c1d335a1f1026/glom-24.11.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-02 23:17:50",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mahmoud",
"github_project": "glom",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "attrs",
"specs": [
[
"==",
"24.2.0"
]
]
},
{
"name": "boltons",
"specs": [
[
"==",
"24.1.0"
]
]
},
{
"name": "cachetools",
"specs": [
[
"==",
"5.5.0"
]
]
},
{
"name": "chardet",
"specs": [
[
"==",
"5.2.0"
]
]
},
{
"name": "colorama",
"specs": [
[
"==",
"0.4.6"
]
]
},
{
"name": "coverage",
"specs": [
[
"==",
"7.2.7"
]
]
},
{
"name": "distlib",
"specs": [
[
"==",
"0.3.9"
]
]
},
{
"name": "exceptiongroup",
"specs": [
[
"==",
"1.2.2"
]
]
},
{
"name": "face",
"specs": [
[
"==",
"24.0.0"
]
]
},
{
"name": "filelock",
"specs": [
[
"==",
"3.12.2"
]
]
},
{
"name": "importlib-metadata",
"specs": [
[
"==",
"6.7.0"
]
]
},
{
"name": "iniconfig",
"specs": [
[
"==",
"2.0.0"
]
]
},
{
"name": "packaging",
"specs": [
[
"==",
"24.0"
]
]
},
{
"name": "platformdirs",
"specs": [
[
"==",
"4.0.0"
]
]
},
{
"name": "pluggy",
"specs": [
[
"==",
"1.2.0"
]
]
},
{
"name": "pyproject-api",
"specs": [
[
"==",
"1.5.3"
]
]
},
{
"name": "pytest",
"specs": [
[
"==",
"7.4.4"
]
]
},
{
"name": "pyyaml",
"specs": [
[
"==",
"6.0.1"
]
]
},
{
"name": "tomli",
"specs": [
[
"==",
"2.0.1"
]
]
},
{
"name": "tox",
"specs": [
[
"==",
"4.8.0"
]
]
},
{
"name": "typing-extensions",
"specs": [
[
"==",
"4.7.1"
]
]
},
{
"name": "virtualenv",
"specs": [
[
"==",
"20.26.6"
]
]
},
{
"name": "zipp",
"specs": [
[
"==",
"3.15.0"
]
]
}
],
"tox": true,
"lcname": "glom"
}