Skip to main content

Command-line to extract information from IVOA VOTables and to convert VOTable back and forth in XML, JSON, YAML, TOML (and to CSV) while preserving all elements (except in CSV).

Project description

votable-cli or VOTCli

Command-line to extract information from IVOA VOTables](https://www.ivoa.net/documents/VOTable/20191021/REC-VOTable-1.4-20191021.html) and to convert efficiently VOTables back and forth in XML, JSON, YAML, TOML (and to CSV) while preserving all elements (except in CSV).

Status

The library this CLI is based on is in an early stage of development. We are (reasonably) open to changes in the various format, e.g.:

  • we could flag attributes with a '@' prefix
  • we could use upper case elements tag names
  • we could remove the 's' suffix in elements arrays
  • we could change the pos_infos name for something else
  • ...

More testing is required, especially the bit type and arrays. Please, provide us with VOTable examples!

To-Do list

  • Support CDATA in TD tags
  • Use the iterator to implement streaming transformations between DATATABLE/BINARY/BINARY2.
  • Also implement streaming conversion to CSV.
  • Implement streaming mode for multiple tables (if it is really useful, please tell me).
  • Add commands to modify a VOTable metadata.
  • Add commands to select/compute columns and filter rows?

Install

From pypi for python users

VOTable cli is available in pypi, you can thus install the vot executable using pip:

pip install votable-cli
vot --help

Debian package

Download the last votable-cli_vxx_yyy.deb corresponding to your architecture (x86_64_musl has the most chances to fit your needs) from the github release page.

Install the .deb by clicking on it or using the command line:

sudo dpkg -i votable-cli_vxx_yyy.deb
sudo apt-get install -f

Then you can use the tool:

vot
man vot

You can uninstall using, e.g.:

sudo dpkg -r $(dpkg -f votable-cli_vxx_yyy.deb Package)

Pre-compile binaries for MacOS, Linux and Windows

Download the last vot-vxx_yyy.tar.gz corresponding to your architecture from the github release page. You probably want ot use:

  • Linux: vot-vxx-x86_64-unknown-linux-musl.tar.gz
  • MacOS: vot-vxx-x86_64-apple-darwin.tar.gz
  • Windows: vot-vxx-.zip

WARNING: for linux, use musl instead of gnu (high chances of uncompatibility in the latter case)

The tar contains a single executable binary file.

tar xzvf vot-vxx-yyy.tar.gz
./vot

Compile from source code

Install rust (and check that ~/.cargo/bin/ is in your path), or update the Rust compiler with:

rustup update

Clone the votable lib rust project:

git clone https://github.com/cds-astro/cds-votable-rust

Install from using cargo:

cargo install --path crates/cli

Help message

> vot --help
Command-line to extract information from IVOA VOTables and to convert them in XML, JSON, YAML, TOML and CSV.

Usage: vot <COMMAND>

Commands:
  convert   Convert a VOTable from one format to another (full table loaded in memory)
  sconvert  Convert a (large) single table VOTable in streaming mode. All information is preserved, even after the `</TABLE>` tag. 
            The `TABLEDATA` to `CSV` conversion preserve fields formatting.
  update    Update metadata from another VOTable of from a CSV file
  get       Get information from a VOTable (sstreaming for XML files)
  help      Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version
> vot convert --help
Convert a VOTable from one format to another (full table loaded in memory)

Usage: vot convert [OPTIONS] --out-fmt <OUTPUT_FMT>

Options:
  -i, --in <FILE>             Path of the input VOTable [default: read from stdin]
  -t, --in-fmt <INPUT_FMT>    Format of the input VOTable ('xml', 'json', 'yaml' or 'toml') [default: guess from file extension]
  -o, --out <FILE>            Path of the output VOTable [default: write to stdout]
  -f, --out-fmt <OUTPUT_FMT>  Format of the output VOTable ('xml', 'xml-td', 'xml-bin', 'xml-bin2', 'json', 'yaml' or 'toml')
  -p, --pretty                Pretty print (for JSON and TOML)
  -h, --help                  Print help
> vot sconvert --help
Convert a (large) single table VOTable in streaming mode. All information is preserved, even after the `</TABLE>` tag. 
The `TABLEDATA` to `CSV` conversion preserve fields formatting.

Usage: vot sconvert [OPTIONS] --out-fmt <OUTPUT_FMT>

Options:
  -i, --in <FILE>                Path of the input XML VOTable [default: read from stdin]
  -o, --out <FILE>               Path of the output file [default: write to stdout]
  -f, --out-fmt <OUTPUT_FMT>     Format of the output file ('xml-td', 'xml-bin', 'xml-bin2' or 'csv')
  -s, --separator <SEPARATOR>    Separator used for the 'csv' format [default: ,]
      --parallel <N>             Exec concurrently using N threads (row order not preserved!)
      --chunk-size <CHUNK_SIZE>  Number of rows process by a same thread in `parallel` mode [default: 10000]
  -h, --help                     Print help
> vot get --help
Get information from a VOTable (sstreaming for XML files)

Usage: vot get [OPTIONS] <COMMAND>

Commands:
  struct        Print the VOTable structure
  colnames      Print column names, one separated values line per table.
  fields-array  Print selected field information as an array
  help          Print this message or the help of the given subcommand(s)

Options:
  -i, --in <FILE>           Path of the input VOTable [default: read from stdin]
  -t, --in-fmt <INPUT_FMT>  Format of the input VOTable ('xml', 'json', 'yaml' or 'toml') [default: guess from file extension]
  -s, --early-stop          Stop parsing before reading first data ('xml' input only)
  -h, --help                Print help

Example

XML/JSON/TOML/YAML convertion

# In memory conversion of a VOTable from XML-TABLEDATA to JSON
vot convert --in my_votable.xml --out my_votable.json --out-fmt json

Streaming conversion XML-TD, XML-BIN, CML-BIN2 and CSV

# Streaming conversion of a VOTable from XML-TABLEDATA to XML-BINARY2
vot sconvert --in my_votable.xml --out my_votable.xml.b64  --out-fmt xml-bin
# Streaming conversion from XML to CSV, in parallel, of a single large table
vot sconvert --in my_votable.xml --out my_votable.csv --out-fmt csv --parallel 6

Get metadata

# Get the structure of a VOTable with virtual identifier for each element
vot get --in my_votable.xml struct --line-width 120
# Get the structure of alarge VOTable till DATA is reached
vot get --in my_votable.xml --early-stop struct --line-width 120
# Get only the colum names of a large table, with a non-ascii separator
vot get --in my_votable.xml --early-stop colnames --separator '▮'
# Get a field metadata array with selected info
vot get -in my_votable.xml fields-array index,name,datatype,arraysize,width,precision,unit,ucd,description --separator ,

Log messages

You can adapt the level of log messages using the environement variable RUST_LOG with one of the following value: error, warn, info, debug, trace and off.

E.g.:

RUST_LOG="trace" vot get --in my_votable.xml struct

See env_logger for more details.

License

Like most projects in Rust, this project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Project details


Download files

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

Source Distribution

votable_cli-0.5.0.tar.gz (150.7 kB view details)

Uploaded Source

Built Distributions

votable_cli-0.5.0-py3-none-win_amd64.whl (2.9 MB view details)

Uploaded Python 3 Windows x86-64

votable_cli-0.5.0-py3-none-manylinux_2_28_x86_64.whl (3.0 MB view details)

Uploaded Python 3 manylinux: glibc 2.28+ x86-64

votable_cli-0.5.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (3.0 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ i686

votable_cli-0.5.0-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (5.5 MB view details)

Uploaded Python 3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

File details

Details for the file votable_cli-0.5.0.tar.gz.

File metadata

  • Download URL: votable_cli-0.5.0.tar.gz
  • Upload date:
  • Size: 150.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.5.0

File hashes

Hashes for votable_cli-0.5.0.tar.gz
Algorithm Hash digest
SHA256 eef50761f4e17743818bb0154753e8535f22024cd41d34325dbd398a0f603ebd
MD5 1c0ec2ee807ef9b1b4408070f1ee92d0
BLAKE2b-256 6c0fc26129ce5ff1b2a5026854bb153da695cc4f73a3b54ffe077427a4e2ce25

See more details on using hashes here.

File details

Details for the file votable_cli-0.5.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for votable_cli-0.5.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 06923051d596104a21327b9ef47776be34184ff2768ac53d6a368531e0e39d41
MD5 e092d091f861002bc0b3933aceb41fb2
BLAKE2b-256 3638509890e8db75f25a5dbe0c69324ccab03677c96ffad2e029137f1016c8b4

See more details on using hashes here.

File details

Details for the file votable_cli-0.5.0-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for votable_cli-0.5.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9f4cd43a15f0408190878833b67d27a1cdd5f5a1623ef0f4eb9cb8b6a16e4558
MD5 39de956c337c310400badb8e7a0804b1
BLAKE2b-256 e777448d5a4df709b21b519098e03b20eb34dafc751e7ef36642b795b24ef2d2

See more details on using hashes here.

File details

Details for the file votable_cli-0.5.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for votable_cli-0.5.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 4233eb44ea12e8fead6f90b8c011633c5694f625b17ebd8052f80eed91f1be7b
MD5 9e9265012f2514673145f9d2eb61d28d
BLAKE2b-256 6b1607247aa861b6230986cd6a3ff89cd9e3e96ee20bb4196af10832f3d1edf2

See more details on using hashes here.

File details

Details for the file votable_cli-0.5.0-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for votable_cli-0.5.0-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 5f6abe728d4f5ea7579c0e36a6807d31a70decb3d1f892173b4bf840e4609be5
MD5 127b7127625edc781ee6e237ddb6a486
BLAKE2b-256 d4c79dbdbc5874fc84e68c1393cdba7408d801d12c76b806c98a7b39cf58025c

See more details on using hashes here.

Supported by

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