Skip to main content

Simple library to make your dictionary flatten

Project description

MakeFlatt

Simple library to make your dictionary flatten in Python

PyPI version PyPI - Python Version Unit Tests Code Style PyPI - License

Installation

pip install makeflatt

Usage

Quick start:

>>> from makeflatt import FlattMaker
>>> mf = FlattMaker()
>>> mf.apply({"a": {"b": {"c": "test"}}})
{'a.b.c': 'test'}

Make nested structured flatten without expanding lists:

>>> mf.apply({"a": {"b": ["b1", "b2", "b3"]}})
{'a.b': ['b1', 'b2', 'b3']}

Or use deep_apply to also expand lists:

>>> mf.deep_apply({"a": {"b": ["b1", "b2", "b3"]}})
{'a.b.0': 'b1', 'a.b.1': 'b2', 'a.b.2': 'b3'}

You can also change the separator and define your own:

>>> mf = FlattMaker(sep=":")
>>> mf.apply({"a": {"b": ["b1", "b2", "b3"]}})
{'a:b': ['b1', 'b2', 'b3']}

License

Makeflatt is released under the MIT Licence. See the bundled LICENSE file for details.

Development

Check the CONTRIBUTING file.

Versioning

This package attempts to use semantic versioning. API changes are indicated by the major version, non-breaking improvements by the minor, and bug fixes in the revision.

It is recommended that you pin your targets to greater or equal to the current version and less than the next major version.

Maintainer

Created and maitained by Jonathan Schweder (@jaswdr)

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

makeflatt-1.0.2.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

makeflatt-1.0.2-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file makeflatt-1.0.2.tar.gz.

File metadata

  • Download URL: makeflatt-1.0.2.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.15 Darwin/21.6.0

File hashes

Hashes for makeflatt-1.0.2.tar.gz
Algorithm Hash digest
SHA256 abd04a5359f59a37f30a526d7e9f564e9bd201f216d767d77d8a9e38b95be0d0
MD5 35485695098009d97db93e9ad5866f51
BLAKE2b-256 e25b758eb59aef5e1b956cf4d1a438b62b5934c87f867aa530db39b83fc8c813

See more details on using hashes here.

File details

Details for the file makeflatt-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: makeflatt-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.15 Darwin/21.6.0

File hashes

Hashes for makeflatt-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 64fe42e995a8e18e12203a0330b39a2dc96f15bfa2de71e8e8959010844f5538
MD5 158accec60d56543a0d804913e248f2d
BLAKE2b-256 8183a9d38ca145fdea5b420be723323a825db2999f6a51346482c075cfb52684

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