Skip to main content

Cat structured data in a shell, i.e. cat some.json user.name.first # echos Janet

Project description

dotcat: Catting Structured Data in Style

dotcat gives your shell the ability to cat + grep structured data.

# With a sample json file:
echo '{"name": "John Doe", "age": 30, "address": {"street": "123 Main St", "city": "Anytown"}}' > data.json

# Get the name
dotcat data.json name
# Output: John Doe

# Get the city
dotcat data.json address.city
# Output: Anytown

# Format the output
dotcat data.json address --format=yaml
# Output:
# street: 123 Main St
# city:
#   Anytown

# Use with a YAML file (data.yaml)
echo 'name: Jane Doe\noccupation: Developer' > data.yaml
dotcat data.yaml occupation
# Output: Developer

# Use array index in path (array.json)
echo '{"items":[{"id":1}, {"id":2}]}' > array.json
dotcat array.json items.1.id
# Output: 2

Key Features

  • Structured Data Extraction: Easily read values from JSON, YAML, TOML, and INI files. No more complex scripting or manual parsing.
  • Dot-Separated Paths: Access deeply nested values using intuitive dot-separated paths (e.g., a.b.c).
  • Configurable Output: Control the output format with --output flag. Choose from:
    • raw: Default. Direct string representation of the extracted value.
    • formatted: Pretty-printed JSON output, ideal for readability.
    • json: Compact JSON output.
    • yaml: YAML output.
    • toml: TOML output.
    • ini: INI output.
  • Clear Error Handling: Provides informative error messages for invalid files, incorrect paths, or unsupported formats.
  • Lightweight and Fast: Built for speed and efficiency.

Installation

pip install dotcat

Usage Basic usage involves specifying the file and the dot-separated key:

dotcat <file> <dot_separated_key> [--output <format>]

Contributing

Contributions are welcome! General

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

dotcat-0.8.2.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

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

dotcat-0.8.2-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file dotcat-0.8.2.tar.gz.

File metadata

  • Download URL: dotcat-0.8.2.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for dotcat-0.8.2.tar.gz
Algorithm Hash digest
SHA256 d8049b66e9afe5914ce9ee255de9f9f3e8dbe8dae1bb548d1df32a3317865d3b
MD5 b339b1591e880b699fc194a4ccb4130a
BLAKE2b-256 691d8743e6c1b833005ef757f3c61f1ba166571f932830b92793629e60e2bcef

See more details on using hashes here.

File details

Details for the file dotcat-0.8.2-py3-none-any.whl.

File metadata

  • Download URL: dotcat-0.8.2-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for dotcat-0.8.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5279de6b8b282c594948da126c64e8088277ac5b6df1fe241bc602dd8b550acf
MD5 991cd7f9c293c8de013acb46f8c12f0e
BLAKE2b-256 2929721e77368688b7bf816d324dbe5cdf0f264904ebcb09f65f390a8e423ae1

See more details on using hashes here.

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