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.0.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.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dotcat-0.8.0.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.0.tar.gz
Algorithm Hash digest
SHA256 a4948fdf682b6895473ba0462ecc48981b06996b95794badd25b506005864894
MD5 484ab8445a6a44dd4dc842a8951873b4
BLAKE2b-256 a4c99f1968d61d5148a93fd760fd373815608ad2a0a09e4346c13737aa6a7c30

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dotcat-0.8.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 efe47c526afc1866329d805a80f12155022826e6cd70320e3c4169b785a9f5c8
MD5 47fe99a3a47ff08f00a671b035d6bca4
BLAKE2b-256 7f9581558afda6351fe1f0d5e4d882d2b34c71e8274c30a166db4075609d8dc7

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