Converts any nested iterable (json, dict, list ...) to an HTML table
#pip install any-iter-to-html-table
from any_iter_to_html_table import create_html_table_from_iterable
data = {
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"],
},
"GlossSee": "markup",
}
},
},
}
}
"""https://json.org/example.html"""
fromjsonorg_result = create_html_table_from_iterable(
data, filename="fromjsonorg.html", title="Pandas - DataFrame", sparsify=True
)
jsonfile = r"F:\jsonstackoverflow.json"
#'https://api.stackexchange.com/2.2/answers?order=desc&sort=activity&site=stackoverflow'
json_from_file = create_html_table_from_iterable(
jsonfile,
filename="json_from_file.html",
title="Pandas - DataFrame",
sparsify=False,
)
sparsify=True
Without CSS
Design is separated from data. You can use the preset, but if you want,
you can easily create your own CSS style
#'https://stackoverflow.com/questions/64359762/constructing-a-pandas-dataframe-with-columns-and-sub-columns-from-nested-diction
nesteddict = {
"level1": {
"t1": {
"s1": {"col1": 5, "col2": 4, "col3": 4, "col4": 9},
"s2": {"col1": 1, "col2": 5, "col3": 4, "col4": 8},
"s3": {"col1": 11, "col2": 8, "col3": 2, "col4": 9},
"s4": {"col1": 5, "col2": 4, "col3": 4, "col4": 9},
},
"t2": {
"s1": {"col1": 5, "col2": 4, "col3": 4, "col4": 9},
"s2": {"col1": 1, "col2": 5, "col3": 4, "col4": 8},
"s3": {"col1": 11, "col2": 8, "col3": 2, "col4": 9},
"s4": {"col1": 5, "col2": 4, "col3": 4, "col4": 9},
},
"t3": {
"s1": {"col1": 1, "col2": 2, "col3": 3, "col4": 4},
"s2": {"col1": 5, "col2": 6, "col3": 7, "col4": 8},
"s3": {"col1": 9, "col2": 10, "col3": 11, "col4": 12},
"s4": {"col1": 13, "col2": 14, "col3": 15, "col4": 16},
},
},
"level2": {
"t1": {
"s1": {"col1": 5, "col2": 4, "col3": 9, "col4": 9},
"s2": {"col1": 1, "col2": 5, "col3": 4, "col4": 5},
"s3": {"col1": 11, "col2": 8, "col3": 2, "col4": 13},
"s4": {"col1": 5, "col2": 4, "col3": 4, "col4": 20},
},
"t2": {
"s1": {"col1": 5, "col2": 4, "col3": 4, "col4": 9},
"s2": {"col1": 1, "col2": 5, "col3": 4, "col4": 8},
"s3": {"col1": 11, "col2": 8, "col3": 2, "col4": 9},
"s4": {"col1": 5, "col2": 4, "col3": 4, "col4": 9},
},
"t3": {
"s1": {"col1": 1, "col2": 2, "col3": 3, "col4": 4},
"s2": {"col1": 5, "col2": 6, "col3": 7, "col4": 8},
"s3": {"col1": 9, "col2": 10, "col3": 11, "col4": 12},
"s4": {"col1": 13, "col2": 14, "col3": 15, "col4": 16},
},
},
}
nested_dict = create_html_table_from_iterable(
nesteddict,
filename="from_nested_dict.html",
title="Pandas - DataFrame",
sparsify=False,
)
Convert any nested iterable to an HTML table. Design is separated from data. You can use the preset, but if you want,
you can easily create your own CSS style.
Parameters:
data: Any
You can pass any iterable (list, dict, tuple …), json file path (str) or json URL (str)
filename: Union[None,str]
File path for output, will be saved in your current working directory
If None, no files will be written.
title: str
Title for HTML
(default = 'Pandas DataFrame')
sparsify: bool
Repeat keys in every line
(default = False)
Returns:
tuple[str,str]
Metadata
Release files for any-iter-to-html-table 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| any_iter_to_html_table-0.1.tar.gz | 7.9 kB | Without provenance | Details for any_iter_to_html_table-0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| any_iter_to_html_table-0.1-py3-none-any.whl | Python 3 | none | any | Details for any_iter_to_html_table-0.1-py3-none-any.whl |
Total release size: 18.2 kB
Release files / any_iter_to_html_table-0.1.tar.gz
| Download URL | any_iter_to_html_table-0.1.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ec4af8f805b6087f20df488e491baf24a3ce4fc9f95c02fb5a00c38a48fcff5b
|
|
BLAKE2b-256 checksum How to use checksums |
616d90101f0895c000dc30cf17e84c1d3964ab8398c18d44689252cf1460b040
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / any_iter_to_html_table-0.1-py3-none-any.whl
| Download URL | any_iter_to_html_table-0.1-py3-none-any.whl |
|---|---|
| Size | 10.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc8456b316e013c0a3871c44cdcdf600e22c189e57472ca49170d87057cb23ac
|
|
BLAKE2b-256 checksum How to use checksums |
85da1db59cc25ec60cc6c90bad11754d666d566a0d758895e8d044e5a38fb066
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Security for any-iter-to-html-table 0.1
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.