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

Uploaded Python 3

File details

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

File metadata

  • Download URL: dotcat-0.8.1.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.1.tar.gz
Algorithm Hash digest
SHA256 ac4dea1b2901c7f552cd9e3346ed4f868b5060db975c3474bb15eee06b09c044
MD5 1b577f0944855b8a8269f376b9e966f6
BLAKE2b-256 303ef0b2d0eef2ebf142592c2b8d39a78005f9121815f17ff88a476f496f68a3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dotcat-0.8.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b1431bc156e7497523d83fef007203a5497dcec484dd9f72d1e786bc4933445d
MD5 940de5589acbff274b03d9d552e030de
BLAKE2b-256 c7e7bd53ecc6ad9f0643c8239196725008efc32aaf31c7b126dff55ac3d8a8b9

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