Skip to main content

tublub

Convert or view tabular data files — CSV, JSON, XLSX, YAML, and more — from the command line.

tublub is a thin wrapper around Tablib. Tablib reads and writes plenty of formats, but it won't open the files for you — you have to know which ones need binary mode, special newline handling, and so on. tublub bakes that per-format knowledge in, so you just point it at a file and it works.

$ tublub --list-formats
Available formats: json xlsx xls yaml csv tsv ods dbf html jira latex rst sql cli

$ tublub input.json
Username |Identifier|First name|Last name
---------|----------|----------|---------
booker12 |9012      |Rachel    |Booker
grey07   |2070      |Laura     |Grey
jenkins46|9346      |Mary      |Jenkins
johnson81|4081      |Craig     |Johnson
smith79  |5079      |Jamie     |Smith

$ tublub input.json output.xlsx

$ file output.xlsx
output.xlsx: Microsoft Excel 2007+

$ tublub -t csv input.json
Username,Identifier,First name,Last name
booker12,9012,Rachel,Booker
grey07,2070,Laura,Grey
jenkins46,9346,Mary,Jenkins
johnson81,4081,Craig,Johnson
smith79,5079,Jamie,Smith

$ tublub -o book.xlsx sales.csv users.json regions.tsv
Saved 'book.xlsx', 3 sheets (xlsx)

With -o, all positional arguments are inputs. Two or more inputs become sheets in a single multi-sheet file (XLSX, ODS, JSON, YAML, ...) — every sheet of every input, so multi-sheet inputs are expanded rather than truncated. Sheets keep their own names, and a whole-file input is named after its file stem; names are only changed when two would collide.

Multi-sheet input

Three rules cover the whole surface:

  1. -s/--sheet picks sheets; selection never changes where output may go. One selected sheet behaves exactly like a single-sheet input does; several behave like a multi-sheet workbook — printed with headings, saved with -o, exported with -t — wherever the output format can hold multiple sheets. --all-sheets is sugar for "select everything".
  2. You can select exactly what -l/--list-sheets shows. Indexed lines ([0] people ...) are selectable by index or title; a bare line means the input has no sheet structure and nothing to select.
  3. Commas are for index lists; repeat -s for names; name: forces a title. So -s 0,2 takes two indices, -s people -s cities takes two titles, and -s name:2024 picks the sheet titled 2024 rather than index 2024.

-l/--list-sheets inspects an input without converting it:

$ tublub -l book.xlsx
[0] people  2 rows x 2 cols
[1] cities  2 rows x 2 cols

$ tublub -l people.csv
2 rows x 2 cols

An input without sheet structure (CSV, TSV, records-shaped JSON, ...) prints one bare N rows x M cols line — there is no index or title to select.

Pick one sheet and it prints like any single-sheet file; pick several and each gets a heading:

$ tublub -s cities book.xlsx
city          pop
Stockholm  975904
Goteborg   583056

$ tublub -s 0,1 book.xlsx
=== people (2 rows) ===
name      age
Alice      30
Bob        41

=== cities (2 rows) ===
city          pop
Stockholm  975904
Goteborg   583056

Converting without any selection converts every sheet, as long as the target format can hold them:

$ tublub book.xlsx out.ods
Saved 'out.ods', 2 sheets (ods)

Single-sheet formats (CSV, TSV, DBF, ...) get the first sheet and always say so on stderr, even when stderr is redirected — tublub never splits one input across several output files:

$ tublub -t csv book.xlsx
book.xlsx: format 'csv' cannot hold all 2 sheets; converting only the first (use -s to choose)
name,age
Alice,30
Bob,41

Asking for every sheet explicitly stays strict: --all-sheets -o out.csv errors instead of quietly dropping data.

All of this works on piped input too, either as an explicit - or implicitly whenever stdin is not a terminal:

$ cat book.xlsx | tublub -l -
[0] people  2 rows x 2 cols
[1] cities  2 rows x 2 cols

News and Changes

Please see the changelog for more details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tublub-0.6.0.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tublub-0.6.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file tublub-0.6.0.tar.gz.

File metadata

  • Download URL: tublub-0.6.0.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for tublub-0.6.0.tar.gz
Algorithm Hash digest
SHA256 78f3e8294266bcdf64b687cb9c58a5789c94b139ffd7b3d3e5821d537061ac74
MD5 6decc7467750d0e3b97a18b2eb31bb42
BLAKE2b-256 ca1a8fb619fdf7484b4aa9364a2e32ce675dd8030b5a92f6c9612fe805874c8c

See more details on using hashes here.

Provenance

The following attestation bundles were made for tublub-0.6.0.tar.gz:

Publisher: python-publish.yml on harkabeeparolus/tublub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tublub-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: tublub-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for tublub-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e5dc190525c06bb7eaebe558d62b8b28ee9ca919187b48ff7e1b97ea82f8b3c7
MD5 0b8d548640dcb07eae5a309f89737c37
BLAKE2b-256 710a040f8101384297d7ffcb74cc58791cc209b1a675aedb1af0e689ce1dd451

See more details on using hashes here.

Provenance

The following attestation bundles were made for tublub-0.6.0-py3-none-any.whl:

Publisher: python-publish.yml on harkabeeparolus/tublub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page