py-data-viewer


Namepy-data-viewer JSON
Version 0.0.8 PyPI version JSON
download
home_pageNone
SummaryA python library to display data structure values for easier navigation and exploration.
upload_time2025-03-22 00:24:31
maintainerNone
docs_urlNone
authorMatt Lucero
requires_python<4.0,>=3.8
licenseMIT
keywords python data viewer debugging exploration
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Py-Data-Viewer

`py-data-viewer` is a lightweight Python library that makes exploring and navigating complex data structures in the terminal effortless. It provides a clear, tree-based visualization of nested dictionaries, lists, objects, and more, making debugging and data analysis more efficient. No more getting lost in complex nested structures or struggling to understand what's inside your data or how to access them! 

> _Trees for complex data structures, Trees for simple data structures, Trees for everything!!_

### No more confusion with complex data structures or asking "what's inside this dictionary!?"

```python
from py_data_viewer import vprint

async def some_async_fn():
    response = await some_api_call()
    vprint(response) # 👈 pass in full response or part of it! It can handle Iterables[of_any_T]!!
```
<img src="img/screen-2.webp" width=80% height=80%>

### No more looking for properties in a long list of dictionaries or objects while in the terminal!
```python
vprint(data, "result")
```

<img src="img/screen-1.webp" width=80% height=80%>


## Features

- **Tree View**: Visualize data structures in the terminal as a tree for better clarity.
- **Colorized Output**: Easily distinguish different parts of the data structure.
- **Supports Multiple Data Types**: Works with dictionaries, lists, objects, namedtuples, and mixed structures.
- **API Response Exploration**: Simplifies debugging and understanding of API responses, especially for complex outputs.
- **Programmatic Usage**: Integrate directly into your Python scripts with the `vprint` function.


## Installation

To install the package, use pip:

```bash
pip install py-data-viewer -U
```

Then, import:
```python
from py_data_viewer import vprint
```

## Usage

### Programmatic Usage with `vprint`

The `vprint` function is the easiest way to explore data structures in your Python scripts. It provides a tree-like visualization of your data, making it ideal for debugging API responses, especially from frameworks!

#### Example: Exploring an API Response

```python
from py_data_viewer import vprint

# Simulated API response
response = {
    "chat_message": {
        "source": "Assistant",
        "content": "This is a response from an LLM.",
        "metadata": {},
    },
    "inner_messages": [
        {
            "type": "ToolCallRequestEvent",
            "content": [{"name": "search", "arguments": '{"query":"example"}'}],
        },
        {
            "type": "ToolCallExecutionEvent",
            "content": [{"name": "search", "content": "Search result here."}],
        },
    ],
}

vprint(response, var_name="messages", colorize=False)
```

Output showing you exactly how to access the data you want:
```
messages
├── messages.chat_message = dict with 3 items
│   ├── messages.chat_message.source = 'Assistant'
│   ├── messages.chat_message.content = 'This is a response from an LLM.'
│   └── messages.chat_message.metadata = dict with 0 items
└── messages.inner_messages = list with 2 items
    ├── messages.inner_messages[0] = dict with 2 items
    │   ├── messages.inner_messages[0].type = 'ToolCallRequestEvent'
    │   └── messages.inner_messages[0].content = list with 1 items
    │       └── messages.inner_messages[0].content[0] = dict with 2 items
    │           ├── messages.inner_messages[0].content[0].name = 'search'
    │           └── messages.inner_messages[0].content[0].arguments = '{"query":"example"}'
    └── messages.inner_messages[1] = dict with 2 items
        ├── messages.inner_messages[1].type = 'ToolCallExecutionEvent'
        └── messages.inner_messages[1].content = list with 1 items
            └── messages.inner_messages[1].content[0] = dict with 2 items
                ├── messages.inner_messages[1].content[0].name = 'search'
                └── messages.inner_messages[1].content[0].content = 'Search result here.'
```

#### Example: Exploring a Complex Data Structure

```python
from py_data_viewer import vprint

data = {
    "user": {"id": 1, "name": "Alice"},
    "actions": [
        {"type": "login", "timestamp": "2023-01-01T12:00:00Z"},
        {"type": "purchase", "details": {"item": "book", "price": 12.99}},
    ],
}

vprint(data, var_name="data")
```


## Advanced Options

The `vprint` function supports several options to customize the output:

- `var_name`: Specify the variable name to display in the output.
- `colorize`: Enable or disable colorized output (default: `True`).

Example:
```python
vprint(data, var_name="custom_data_name", colorize=False)
```


## Contributing

Contributions are welcome! To contribute:

1. Fork the repository.
2. Create a new branch for your feature or bugfix.
3. Commit your changes and push the branch.
4. Open a pull request.


## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.


## Links

- **Homepage**: [GitHub Repository](https://github.com/Attention-Mechanism/py-data-viewer)
- **Issues**: [Report Issues](https://github.com/Attention-Mechanism/py-data-viewer)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "py-data-viewer",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "python, data, viewer, debugging, exploration",
    "author": "Matt Lucero",
    "author_email": "matt_lucero@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/a2/61/b3a0e6e5ed8800b86a552120dcfae2b5fbbb6eae9c98805df2ea6963cab4/py_data_viewer-0.0.8.tar.gz",
    "platform": null,
    "description": "# Py-Data-Viewer\n\n`py-data-viewer` is a lightweight Python library that makes exploring and navigating complex data structures in the terminal effortless. It provides a clear, tree-based visualization of nested dictionaries, lists, objects, and more, making debugging and data analysis more efficient. No more getting lost in complex nested structures or struggling to understand what's inside your data or how to access them! \n\n> _Trees for complex data structures, Trees for simple data structures, Trees for everything!!_\n\n### No more confusion with complex data structures or asking \"what's inside this dictionary!?\"\n\n```python\nfrom py_data_viewer import vprint\n\nasync def some_async_fn():\n    response = await some_api_call()\n    vprint(response) # \ud83d\udc48 pass in full response or part of it! It can handle Iterables[of_any_T]!!\n```\n<img src=\"img/screen-2.webp\" width=80% height=80%>\n\n### No more looking for properties in a long list of dictionaries or objects while in the terminal!\n```python\nvprint(data, \"result\")\n```\n\n<img src=\"img/screen-1.webp\" width=80% height=80%>\n\n\n## Features\n\n- **Tree View**: Visualize data structures in the terminal as a tree for better clarity.\n- **Colorized Output**: Easily distinguish different parts of the data structure.\n- **Supports Multiple Data Types**: Works with dictionaries, lists, objects, namedtuples, and mixed structures.\n- **API Response Exploration**: Simplifies debugging and understanding of API responses, especially for complex outputs.\n- **Programmatic Usage**: Integrate directly into your Python scripts with the `vprint` function.\n\n\n## Installation\n\nTo install the package, use pip:\n\n```bash\npip install py-data-viewer -U\n```\n\nThen, import:\n```python\nfrom py_data_viewer import vprint\n```\n\n## Usage\n\n### Programmatic Usage with `vprint`\n\nThe `vprint` function is the easiest way to explore data structures in your Python scripts. It provides a tree-like visualization of your data, making it ideal for debugging API responses, especially from frameworks!\n\n#### Example: Exploring an API Response\n\n```python\nfrom py_data_viewer import vprint\n\n# Simulated API response\nresponse = {\n    \"chat_message\": {\n        \"source\": \"Assistant\",\n        \"content\": \"This is a response from an LLM.\",\n        \"metadata\": {},\n    },\n    \"inner_messages\": [\n        {\n            \"type\": \"ToolCallRequestEvent\",\n            \"content\": [{\"name\": \"search\", \"arguments\": '{\"query\":\"example\"}'}],\n        },\n        {\n            \"type\": \"ToolCallExecutionEvent\",\n            \"content\": [{\"name\": \"search\", \"content\": \"Search result here.\"}],\n        },\n    ],\n}\n\nvprint(response, var_name=\"messages\", colorize=False)\n```\n\nOutput showing you exactly how to access the data you want:\n```\nmessages\n\u251c\u2500\u2500 messages.chat_message = dict with 3 items\n\u2502   \u251c\u2500\u2500 messages.chat_message.source = 'Assistant'\n\u2502   \u251c\u2500\u2500 messages.chat_message.content = 'This is a response from an LLM.'\n\u2502   \u2514\u2500\u2500 messages.chat_message.metadata = dict with 0 items\n\u2514\u2500\u2500 messages.inner_messages = list with 2 items\n    \u251c\u2500\u2500 messages.inner_messages[0] = dict with 2 items\n    \u2502   \u251c\u2500\u2500 messages.inner_messages[0].type = 'ToolCallRequestEvent'\n    \u2502   \u2514\u2500\u2500 messages.inner_messages[0].content = list with 1 items\n    \u2502       \u2514\u2500\u2500 messages.inner_messages[0].content[0] = dict with 2 items\n    \u2502           \u251c\u2500\u2500 messages.inner_messages[0].content[0].name = 'search'\n    \u2502           \u2514\u2500\u2500 messages.inner_messages[0].content[0].arguments = '{\"query\":\"example\"}'\n    \u2514\u2500\u2500 messages.inner_messages[1] = dict with 2 items\n        \u251c\u2500\u2500 messages.inner_messages[1].type = 'ToolCallExecutionEvent'\n        \u2514\u2500\u2500 messages.inner_messages[1].content = list with 1 items\n            \u2514\u2500\u2500 messages.inner_messages[1].content[0] = dict with 2 items\n                \u251c\u2500\u2500 messages.inner_messages[1].content[0].name = 'search'\n                \u2514\u2500\u2500 messages.inner_messages[1].content[0].content = 'Search result here.'\n```\n\n#### Example: Exploring a Complex Data Structure\n\n```python\nfrom py_data_viewer import vprint\n\ndata = {\n    \"user\": {\"id\": 1, \"name\": \"Alice\"},\n    \"actions\": [\n        {\"type\": \"login\", \"timestamp\": \"2023-01-01T12:00:00Z\"},\n        {\"type\": \"purchase\", \"details\": {\"item\": \"book\", \"price\": 12.99}},\n    ],\n}\n\nvprint(data, var_name=\"data\")\n```\n\n\n## Advanced Options\n\nThe `vprint` function supports several options to customize the output:\n\n- `var_name`: Specify the variable name to display in the output.\n- `colorize`: Enable or disable colorized output (default: `True`).\n\nExample:\n```python\nvprint(data, var_name=\"custom_data_name\", colorize=False)\n```\n\n\n## Contributing\n\nContributions are welcome! To contribute:\n\n1. Fork the repository.\n2. Create a new branch for your feature or bugfix.\n3. Commit your changes and push the branch.\n4. Open a pull request.\n\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n\n## Links\n\n- **Homepage**: [GitHub Repository](https://github.com/Attention-Mechanism/py-data-viewer)\n- **Issues**: [Report Issues](https://github.com/Attention-Mechanism/py-data-viewer)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A python library to display data structure values for easier navigation and exploration.",
    "version": "0.0.8",
    "project_urls": {
        "Homepage": "https://github.com/Attention-Mechanism/py-data-viewer",
        "Repository": "https://github.com/Attention-Mechanism/py-data-viewer"
    },
    "split_keywords": [
        "python",
        " data",
        " viewer",
        " debugging",
        " exploration"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "07b6123d9a6f411fd3c89bc467a9cf40cc3724ce60955fef47b5223172643dc6",
                "md5": "9909b9612181b1de07c02f0553780a32",
                "sha256": "64770d3a61562edf716703c6aa71f82f72f9892b545158f23e0ce30d805245bc"
            },
            "downloads": -1,
            "filename": "py_data_viewer-0.0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9909b9612181b1de07c02f0553780a32",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 8584,
            "upload_time": "2025-03-22T00:24:30",
            "upload_time_iso_8601": "2025-03-22T00:24:30.529906Z",
            "url": "https://files.pythonhosted.org/packages/07/b6/123d9a6f411fd3c89bc467a9cf40cc3724ce60955fef47b5223172643dc6/py_data_viewer-0.0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a261b3a0e6e5ed8800b86a552120dcfae2b5fbbb6eae9c98805df2ea6963cab4",
                "md5": "b12d6c862ab819cd19864788cccba149",
                "sha256": "44f0f7c9a0c78d4fe5db361e17720886fca74bc52e7f77f930d0378f4dfeb808"
            },
            "downloads": -1,
            "filename": "py_data_viewer-0.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "b12d6c862ab819cd19864788cccba149",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 8256,
            "upload_time": "2025-03-22T00:24:31",
            "upload_time_iso_8601": "2025-03-22T00:24:31.707255Z",
            "url": "https://files.pythonhosted.org/packages/a2/61/b3a0e6e5ed8800b86a552120dcfae2b5fbbb6eae9c98805df2ea6963cab4/py_data_viewer-0.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-03-22 00:24:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Attention-Mechanism",
    "github_project": "py-data-viewer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "py-data-viewer"
}
        
Elapsed time: 0.42776s