Skip to main content

Introduction

Gviz Data Table is a simple Python library for converting Python data types to the Google Visualization Data Table JSON format. https://developers.google.com/chart/interactive/docs/reference

The Google Visualization Library itself is a Javascript library that provides interactive charts that work in pretty much any browser. The libraries cover most use cases including tables, as well as charts, so you can have a chart and a table of the same data.

Gviz Data Table is designed primarily for use with data sources such as databases. Usage is supposed to be minimal: you provide a schema, that is a list of columns, and the rows of data. A column must have a name and Python data type. It can also have a label which will be used for display, otherwise the name will be used.

Each row is a sequence of cells. Although columns are explicit row names are always the first cell in a row. Like columns, cells can also have labels. Gviz Data Table will validate each cell to make sure that data conforms to type specified in the schema and will map Python types to their JSON equivalent but it does not coerce any data, i.e. if a column has type int and a cell’s data is a string containing numerical characters only this will still raise an exception.

Gviz Data Table handles data conversion only. You will need to add the necessary Javascript to an web page in order for any charts or table to be drawn. Tables, columns and cells can all have options which are just dictionaries. As there is no further definition of options no validation of their items occurs. Unknown items will simply be ignored.

Gviz Data Table is composed of: one container class Table; two data classes, Cell and Column and one JSON encoder. Application code should probably only ever need to use Table and the encoder.

Usage

Tables can be initialised with a schema or these can be added imperatively. Once one row has been added to a table no more columns can be added. Once all the rows have been added. The table can be converted into JSON using the encoder.

Example

Let’s say we have data representing the names and salaries of people

Name

Salary

Jim

50

Bob

80

This could be coded in Gviz Data Table like this:

from gviz_data_table import Table

table = Table()
table.add_column('name', str, "Name")
table.add_column('salary', int, "Salary")
table.append(["Jim", 50])
table.append(["Bob", 80])

This can be encoded into JSON using the encoder:

from gviz_data_table import encode

encode(table)

It can also be directly encoded

table.encode()

And also used as a static data source for asynchronous loading from Javascript

table.source()

Metadata

Release files for gviz-data-table 2.0.0

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

Source distribution (sdist)

Source distribution for gviz-data-table 2.0.0
File Size Uploaded Provenance Actions
gviz_data_table-2.0.0.tar.gz 11.2 kB Without provenance Details for gviz_data_table-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gviz-data-table 2.0.0
File Interpreter ABI Platform Actions
gviz_data_table-2.0.0-py2.py3-none-any.whl Python 3, Python 2 none any Details for gviz_data_table-2.0.0-py2.py3-none-any.whl

Total release size: 22.5 kB

Release files / gviz_data_table-2.0.0.tar.gz

Download URL gviz_data_table-2.0.0.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d34f4292fb7002b23e7087e821c4eba895be3fffae4de1c461f9f2214fbf4866
BLAKE2b-256 checksum
How to use checksums
c36a516ba42f4e85c548508a2aee130b0a5531f13e5517a9adab77dd676dcdf6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / gviz_data_table-2.0.0-py2.py3-none-any.whl

Download URL gviz_data_table-2.0.0-py2.py3-none-any.whl
Size 11.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
2512170f5ee3068d979dcdf29be951d0f8b0008e8ac9520e74f715c3b984ee20
BLAKE2b-256 checksum
How to use checksums
f5f58bf572ec100f5269eeebcdc13f2f05c14ead573c785aeb00464f55719750
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Security for gviz-data-table 2.0.0

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