Skip to main content

A python library to display data structure values for easier navigation and exploration.

Project description

Data Viewer

Data Viewer is a Python library designed to help mushroom people (like me) explore and navigate complex data structures with ease. It provides a clear view of nested dictionaries, lists, objects, and more, making debugging and data analysis more efficient.


Features

  • Tree View: Visualize data structures 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:

pip install py-data-viewer

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

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="response")

Output:

response
├── response.chat_message = dict with 3 items
│   ├── response.chat_message.source = 'Assistant'
│   ├── response.chat_message.content = 'This is a response from an LLM.'
│   └── response.chat_message.metadata = dict with 0 items
└── response.inner_messages = list with 2 items
    ├── response.inner_messages[0] = dict with 2 items
    │   ├── response.inner_messages[0].type = 'ToolCallRequestEvent'
    │   └── response.inner_messages[0].content = list with 1 items
    │       └── response.inner_messages[0].content[0] = dict with 2 items
    │           ├── response.inner_messages[0].content[0].name = 'search'
    │           └── response.inner_messages[0].content[0].arguments = '{"query":"example"}'
    └── response.inner_messages[1] = dict with 2 items
        ├── response.inner_messages[1].type = 'ToolCallExecutionEvent'
        └── response.inner_messages[1].content = list with 1 items
            └── response.inner_messages[1].content[0] = dict with 2 items
                ├── response.inner_messages[1].content[0].name = 'search'
                └── response.inner_messages[1].content[0].content = 'Search result here.'

Example: Exploring a Complex Data Structure

from 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", tree_view=True)

Advanced Options

The vprint function supports several options to customize the output:

  • var_name: Specify the variable name to display in the output.
  • indent_size: Set the number of spaces for indentation (default: 2).
  • colorize: Enable or disable colorized output (default: True).

Example:

vprint(data, var_name="custom_data_name", indent_size=4, 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 file for details.


Links

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

py_data_viewer-0.0.4.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_data_viewer-0.0.4-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file py_data_viewer-0.0.4.tar.gz.

File metadata

  • Download URL: py_data_viewer-0.0.4.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for py_data_viewer-0.0.4.tar.gz
Algorithm Hash digest
SHA256 42546009b366758b3bd78ad62cd4a09288e7f0da4f50cea5293ed4c4656d9b53
MD5 c0d990c2450d66db4caf6a2d1399730e
BLAKE2b-256 ca8e7347311acb2c642c3e3f4143b79b60b5f3ce78acd6e1f980061a0d66e5cb

See more details on using hashes here.

File details

Details for the file py_data_viewer-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: py_data_viewer-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for py_data_viewer-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 38b9885065833206c56dd2d194fde4e8aff64f49c99c8e72e7ff52123d168eae
MD5 3c5b34cca49de1146be0c08adbe54cbb
BLAKE2b-256 ebd799df1484d667adb689f1936c6076c4143bec5e7d780cb883c8c5373a88b9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page