Simple library to make your dictionary flatten
Project description
MakeFlatt
Simple library to make your dictionary flatten in Python
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
Built Distribution
File details
Details for the file makeflatt-1.0.1.tar.gz
.
File metadata
- Download URL: makeflatt-1.0.1.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.10 CPython/3.8.15 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6a6728462b28674e958b51968f25f201718681cdb036a413228d287e6fa5699 |
|
MD5 | 8a4812788f11fed8f5dc2410db0625c4 |
|
BLAKE2b-256 | 90104e1c7f044a592b876d436b961abd65eec315ecac6bba55944fc5149a5def |
File details
Details for the file makeflatt-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: makeflatt-1.0.1-py3-none-any.whl
- Upload date:
- Size: 3.3 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4012febde647ce752f7e62a60380308a2338f0d4adaf1dfeeeff8f9fcfcd4699 |
|
MD5 | aaba8614d872373b46d944660c4b62ef |
|
BLAKE2b-256 | 91c2f108177f72c3cfad19708e0d21b429b304e91081bf868523b94c879d3dd5 |