A python library to display data structure values for easier navigation and exploration.
Project description
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
vprintfunction.
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:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Commit your changes and push the branch.
- Open a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Links
- Homepage: GitHub Repository
- Issues: Report Issues
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_data_viewer-0.0.7.tar.gz.
File metadata
- Download URL: py_data_viewer-0.0.7.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.13.2 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37a0faedfb431db096eb22695ebdd914adca3e6ad436e440366d0533e3f2cd6e
|
|
| MD5 |
a6e476bbce70c7190af1ddfa4dc7b1f3
|
|
| BLAKE2b-256 |
9ceba6aa6d0a01deda4b2c1413c75f7b0a50ae9ae3e86ab5e3947622eb7d09fc
|
File details
Details for the file py_data_viewer-0.0.7-py3-none-any.whl.
File metadata
- Download URL: py_data_viewer-0.0.7-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.13.2 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02336e1ba9dd6e8eb39400152d794ba114f75097ef6eaa86d2f49c0d63373a03
|
|
| MD5 |
052c4f166677c6af114d25152fd8e265
|
|
| BLAKE2b-256 |
32cd2436c778fd282c6f70873e78dc6cdf2a2c1f4a2a6724a96f044cf8a09d08
|