yq is a Python-based command-line processor for YAML, XML, and TOML documents, acting as a lightweight wrapper that transparently converts these formats to JSON and pipes them to the `jq` command-line tool for querying and manipulation. It's currently at version 3.4.3 and maintains an active release cadence with regular updates and fixes.
pip install yqNo compatibility data collected yet for this library.
The `yq` library primarily provides command-line utilities (`yq`, `xq`, `tomlq`). To use it programmatically in Python, you typically invoke these commands via `subprocess`. This example demonstrates how to create a YAML file, extract a value, and perform a transformation using `yq`.
Install `jq` via your system's package manager (e.g., `brew install jq` on macOS, `sudo apt-get install jq` on Debian/Ubuntu).
Review outputs for YAML documents containing strings starting with '08' or '09'. If consistent non-quoted output is required, consider post-processing or adjusting input data if possible.
Be cautious when handling YAML/XML/TOML data that might contain strings like '08' or '09'. Ensure your version of `yq` (and `PyYAML` indirectly) handles these as strings or explicitly quote them in your source data.
Ensure you are using `yq` version 3.2.0 or newer for improved TOML parsing capabilities, especially if round-trip fidelity is important.
Install yq using `pip install yq` and ensure your system's PATH environment variable includes the directory where pip installs executables (e.g., `~/.local/bin` on Linux/macOS or `C:\PythonXX\Scripts` on Windows).
Install `jq` separately for your operating system (e.g., `brew install jq` on macOS, `sudo apt-get install jq` on Debian/Ubuntu, `choco install jq` on Windows) and verify it's in your PATH.
Wrap your `jq` query in a single set of quotes (e.g., `yq '.foo | .bar' my_file.yaml`) to ensure it is parsed as one argument.
Pass `jq` flags within the `jq` query string (e.g., `yq -y '.foo | @text' my_file.yaml` for raw text output), or pipe `yq`'s output to `jq` directly (e.g., `yq .foo my_file.yaml | jq -r .`).