Skip to main content

htmltable cli

Command line tool to convert lists to portable HTML tables with embedded audios and images.

Installation

From source (latest)

pip install git+https://github.com/FarisHijazi/htmltable-cli

From PyPi (table)

pip install htmltable-cli

Usage

usage:

A command line tool to generate html tables with embedded images, videos and audio

- Separate columns with `,` or pass all files and group by parent using `--groupy_nthparent 1`
- The easiest way to use it is to put each column in a folder and then pass it using a wildcard `*`

Examples:

    htmltable col1/*.* , col2/*.* , col3/*.* --title "my table" --controls controls preload autoplay loop muted --base64 --index > output.html
    htmltable col*/* --groupy_nthparent 1    --title "my table" --controls controls preload autoplay loop muted --base64 --index > output.html

    [-h] [--title TITLE] [-g GROUPY_NTHPARENT] [-c COLNAMES [COLNAMES ...]] [-b] [-x | -fx]
    [--controls [{controls,preload,autoplay,loop,muted} [{controls,preload,autoplay,loop,muted} ...]]] [-t] [--clamp]
    data [data ...]

positional arguments:
data                  input table data. Format: col1_item1 col1_item2 col1_item3 , col2_item1 col2_item2 col2_item3 ...

optional arguments:
-h, --help            show this help message and exit
--title TITLE         title heading for the table
-g GROUPY_NTHPARENT, --groupy_nthparent GROUPY_NTHPARENT
                        choose columns based on the nth parent, instead of separating using "," delimiter to determine
                        columns.This allows to dynamically specify folders instead of passing folders explicitly with "," in
                        between. Set to -g 1 for the direct parent of the files
-c COLNAMES [COLNAMES ...], --colnames COLNAMES [COLNAMES ...]
                        Provide a list of column names (instead of automatically inferring column names from filepaths).
-b, --base64          Encode all the media to a base64 URL, meaning that the html file is now portable and doesn't depend
                        on the location of the images/audios/videos
-x, --index           add numerical index column
-fx, --filename_index
                        Infer index (rowname) based on row filenames, instead of numerical index. All columns must have
                        identical filenames otherwise an error is raised
--controls [{controls,preload,autoplay,loop,muted} [{controls,preload,autoplay,loop,muted} ...]]
                        HTML video and audio controls
-t, --transpose       swap columns and rows
--clamp               clamp number of rows to the shortest row, ensures the table is symmetric.

Assuming filestructure:

.
|-- col1
|   |-- audio1.wav
|   |-- ...
|   |-- image.png
|   `-- video.mp4
|-- col2
|   |-- audio1.wav
|   |-- ...
|   |-- image.png
|   `-- video.mp4
`-- col3
    |-- audio1.wav
    |-- ...
    |-- image.png
    `-- video.mp4

Examples

Minimal example

htmltable col1/audio1.wav , col2/audio1.wav , col3/audio1.wav > output.html

or for dynamically choosing folders using wildcards *. This will pass all files, and then will group them by parent folder, in this case 1 means the first parent folder.

htmltable col*/* --groupy_nthparent 1 > output.html

More involved example

htmltable col1/*.* , \
          col2/*.* , \
          col3/*.* \
          --controls controls preload autoplay loop muted \
          --base64 --index > output.html

(you don't actually have to organize your arguments in a new lines :p)

Explanation
  • --base64 will encode all the media to a base64 URL, meaning that the html file is now portable and doesn't depend on the location of the images/audios/videos
  • col1/*.* passes all files in col1/ directory
  • --controls controls preload autoplay loop muted set default video and audio attributes

Column and row headers

  • Column headers are inferred automatically, to manually specify column names, use -c/--colnames
  • Row headers options:
    • Can be left blank

    • Indexed numerically using -x/--index

    • Use the filenames, if all files have the same name across columns, using -fx/--filename_index.

      Example: col1/audio1.wav, col2/audio2.wav.

Known issues

  • Outputting files is only supported in the . dir. i.e htmltable .... > some/other/path/output.html has issues when not using --base64
  • setting --controls autoplay won't work, you need to add muted as well

Development

Before committing, run the test script and make sure the output .html files are as expected

sh test.sh; ls testoutput*.html | xargs -I{} xdg-open {}  # for linux debian
sh test.sh; ls testoutput*.html | xargs -I{} start {}     # for windows

For building a release and uploading it to PyPi, make and git commit your changes, then run

sh build.sh

Metadata

Release files for htmltable-cli 0.1.11

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

Source distribution (sdist)

Source distribution for htmltable-cli 0.1.11
File Size Uploaded
htmltable-cli-0.1.11.tar.gz 6.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for htmltable-cli 0.1.11
File Interpreter ABI Platform
htmltable_cli-0.1.11-py3-none-any.whl Python 3 none any Details

Total release size: 14.1 kB

Release files / htmltable-cli-0.1.11.tar.gz

Download URL htmltable-cli-0.1.11.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9e0abee4138373f1b51688209552c5234f123707ab9aa65cf6e3fbb1a9669074
BLAKE2b-256 checksum
How to use checksums
b5af5828efc64ed516487683965b0930fa7701150e13f487b48132b3ac25d19d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Release files / htmltable_cli-0.1.11-py3-none-any.whl

Download URL htmltable_cli-0.1.11-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
560418204f41cafb2a8fe86ba04907489e355996f1a6519806bc630b054be528
BLAKE2b-256 checksum
How to use checksums
46b67e7e69e019449c554c62a371345fbb980ffe82311e116f8b90476785e53f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Release history Release notifications | RSS feed

This release

0.1.11 This release

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

3 release files

0.0.1

2 release files

0.0.0

1 release file

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