nested2nested


Namenested2nested JSON
Version 0.10 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/nested2nested
Summaryconverts a nested list into a nested dictionary with support for multi-level keys and preserving the order
upload_time2023-07-11 06:23:29
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords nested iterables dict
VCS
bugtrack_url
requirements flatten_any_dict_iterable_or_whatsoever multikeyiterdict
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# converts a nested list into a nested dictionary with support for multi-level keys and preserving the order

## pip install nested2nested 

#### Tested against Windows 10 / Python 3.10 / Anaconda 


### Conversion of nested lists to nested dictionaries: 

The function provides a convenient way to convert nested lists into nested dictionaries. This can be useful when working with data structures that require a hierarchical representation, such as JSON-like structures or when organizing data in a tree-like format.

### Support for multi-level keys: 

The function utilizes the MultiKeyIterDict class, which allows the use of multi-level keys in the resulting nested dictionary. This means that each level of the nested list can be represented as a key in the corresponding level of the dictionary.

### Preservation of order: 

The MultiKeyIterDict class used in the function preserves the order of elements during conversion. This is important when the order of elements in the nested list needs to be maintained in the resulting dictionary.

### Flexibility and reusability: 

The function is designed to be flexible and can handle nested lists of any depth or structure. It uses a separate module, flatten_any_dict_iterable_or_whatsoever, to flatten the nested list, making it adaptable to various use cases. The MultiKeyIterDict class can also be used independently for other projects involving multi-level dictionaries.

This function can be useful for developers or data analysts working with hierarchical or nested data structures. It simplifies the process of converting nested lists to nested dictionaries and provides flexibility in handling multi-level keys. It can be applied in various domains, including data manipulation, data preprocessing, and working with complex data structures.

```python
from nested2nested import nested_list_to_nested_dict
d = nested_list_to_nested_dict(l=[33, 4, ['baba', 4, ['babx', [[4, 4, 5, 2], 4], 4, 32], 4, 3], 423])
print(d)
{
    0: 33,
    1: 4,
    2: {
        0: 'baba',
        1: 4,
        2: {
            0: 'babx',
            1: {
                0: {
                    0: 4,
                    1: 4,
                    2: 5,
                    3: 2
                },
                1: 4
            },
            2: 4,
            3: 32
        },
        3: 4,
        4: 3
    },
    3: 423
}


```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/nested2nested",
    "name": "nested2nested",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "nested iterables,dict",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/12/5b/f8b5944f288f7875c18a4472bd718b69f2e8a1301a0e46c5a9ba1d0fcebb/nested2nested-0.10.tar.gz",
    "platform": null,
    "description": "\r\n# converts a nested list into a nested dictionary with support for multi-level keys and preserving the order\r\n\r\n## pip install nested2nested \r\n\r\n#### Tested against Windows 10 / Python 3.10 / Anaconda \r\n\r\n\r\n### Conversion of nested lists to nested dictionaries: \r\n\r\nThe function provides a convenient way to convert nested lists into nested dictionaries. This can be useful when working with data structures that require a hierarchical representation, such as JSON-like structures or when organizing data in a tree-like format.\r\n\r\n### Support for multi-level keys: \r\n\r\nThe function utilizes the MultiKeyIterDict class, which allows the use of multi-level keys in the resulting nested dictionary. This means that each level of the nested list can be represented as a key in the corresponding level of the dictionary.\r\n\r\n### Preservation of order: \r\n\r\nThe MultiKeyIterDict class used in the function preserves the order of elements during conversion. This is important when the order of elements in the nested list needs to be maintained in the resulting dictionary.\r\n\r\n### Flexibility and reusability: \r\n\r\nThe function is designed to be flexible and can handle nested lists of any depth or structure. It uses a separate module, flatten_any_dict_iterable_or_whatsoever, to flatten the nested list, making it adaptable to various use cases. The MultiKeyIterDict class can also be used independently for other projects involving multi-level dictionaries.\r\n\r\nThis function can be useful for developers or data analysts working with hierarchical or nested data structures. It simplifies the process of converting nested lists to nested dictionaries and provides flexibility in handling multi-level keys. It can be applied in various domains, including data manipulation, data preprocessing, and working with complex data structures.\r\n\r\n```python\r\nfrom nested2nested import nested_list_to_nested_dict\r\nd = nested_list_to_nested_dict(l=[33, 4, ['baba', 4, ['babx', [[4, 4, 5, 2], 4], 4, 32], 4, 3], 423])\r\nprint(d)\r\n{\r\n    0: 33,\r\n    1: 4,\r\n    2: {\r\n        0: 'baba',\r\n        1: 4,\r\n        2: {\r\n            0: 'babx',\r\n            1: {\r\n                0: {\r\n                    0: 4,\r\n                    1: 4,\r\n                    2: 5,\r\n                    3: 2\r\n                },\r\n                1: 4\r\n            },\r\n            2: 4,\r\n            3: 32\r\n        },\r\n        3: 4,\r\n        4: 3\r\n    },\r\n    3: 423\r\n}\r\n\r\n\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "converts a nested list into a nested dictionary with support for multi-level keys and preserving the order",
    "version": "0.10",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/nested2nested"
    },
    "split_keywords": [
        "nested iterables",
        "dict"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b9b8b2244f3ebe80b7a8a67fdf0b0baad4ac7366a973b75b8090957037d6059f",
                "md5": "a87bcd133c18362ceb2624631b5a9715",
                "sha256": "71e1923f66727e0aee62ddb5f2ffc90dd91da1115070414b44ac5f7bbecf4f80"
            },
            "downloads": -1,
            "filename": "nested2nested-0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a87bcd133c18362ceb2624631b5a9715",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 6028,
            "upload_time": "2023-07-11T06:23:27",
            "upload_time_iso_8601": "2023-07-11T06:23:27.712968Z",
            "url": "https://files.pythonhosted.org/packages/b9/b8/b2244f3ebe80b7a8a67fdf0b0baad4ac7366a973b75b8090957037d6059f/nested2nested-0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "125bf8b5944f288f7875c18a4472bd718b69f2e8a1301a0e46c5a9ba1d0fcebb",
                "md5": "444bf73e6392e8c1b77c38b89a9f5da5",
                "sha256": "d5048133dcd16338744d286fc27afbc63a6d5cb844701869b11f73a5db7d3299"
            },
            "downloads": -1,
            "filename": "nested2nested-0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "444bf73e6392e8c1b77c38b89a9f5da5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4047,
            "upload_time": "2023-07-11T06:23:29",
            "upload_time_iso_8601": "2023-07-11T06:23:29.445799Z",
            "url": "https://files.pythonhosted.org/packages/12/5b/f8b5944f288f7875c18a4472bd718b69f2e8a1301a0e46c5a9ba1d0fcebb/nested2nested-0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-11 06:23:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "nested2nested",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "flatten_any_dict_iterable_or_whatsoever",
            "specs": []
        },
        {
            "name": "multikeyiterdict",
            "specs": []
        }
    ],
    "lcname": "nested2nested"
}
        
Elapsed time: 0.08516s