Skip to main content

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!?"

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]!!

No more looking for properties in a long list of dictionaries or objects while in the terminal!

vprint(data, "result")

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:

pip install py-data-viewer -U

Then, import:

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

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

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:

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 file for details.

Metadata

Release files for py-data-viewer 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-data-viewer 0.0.9
File Size Uploaded Provenance Actions
py_data_viewer-0.0.9.tar.gz 7.6 kB Without provenance Details for py_data_viewer-0.0.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py-data-viewer 0.0.9
File Interpreter ABI Platform Actions
py_data_viewer-0.0.9-py3-none-any.whl Python 3 none any Details for py_data_viewer-0.0.9-py3-none-any.whl

Total release size: 16.5 kB

Release files / py_data_viewer-0.0.9.tar.gz

Download URL py_data_viewer-0.0.9.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b4db72820218ecd0e4277d5efe6aaa9c43a8b6b1121fb6f963aa4a4470ac25bd
BLAKE2b-256 checksum
How to use checksums
a2dfa6ebb4ab19354f5b366ffc28f6d66baeceffefc6ceca47c10d17789bd6b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.13.2 Windows/11

Release files / py_data_viewer-0.0.9-py3-none-any.whl

Download URL py_data_viewer-0.0.9-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
84bea4546aee8843d2abdb96783feb637d01c860c8eecd2b0a774d5bd7e76773
BLAKE2b-256 checksum
How to use checksums
8a2cf9a7aee071a374f00ab5c366b155c862468e0b9a4d4179f6c4e90f406230
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.13.2 Windows/11

Security for py-data-viewer 0.0.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page