Registry / data / niet
library3.2.0pypypiunverified

Niet is a powerful command-line interface (CLI) tool designed for efficient interaction with YAML, JSON, and TOML data files. It allows users to slice, filter, map, transform, and convert structured data using simple expressions or advanced XPath features directly from the shell. Written in Python, `niet` is actively maintained, with its latest version 3.2.0 released in April 2023.

pip install niet
INSTALL
IMPORT
SIG · NIET
N
niet
datapythonv3.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

This quickstart demonstrates basic data extraction from YAML and JSON files using `niet`. First, it creates a sample `config.yaml` file and extracts the project name. Then, it creates a `data.json` file and extracts a specific item's value using a filter expression.

echo "---\nproject:\n meta:\n name: my-app\n version: 1.0.0" > config.yaml niet config.yaml "project.meta.name" # Expected output: my-app echo '{"data": {"items": [{"id": 1, "value": "alpha"}, {"id": 2, "value": "beta"}]}}' > data.json niet data.json "data.items[?id=2].value" # Expected output: beta
niet --version
Debug
Known issues
breakingPython 2.7 support was dropped in `niet` version 2.0. If you require Python 2.7, you must use a version of `niet` lower than 2.0.
fix
Upgrade to Python 3.9+ or use `niet<2.0` (not recommended as it's unsupported).
affects: < 2.0
gotcha`niet` is primarily a command-line interface tool and is not designed for direct programmatic import and use within Python scripts like a typical library. All core functionalities are exposed via its CLI.
fix
To integrate `niet` functionality into Python scripts, use `subprocess` calls to execute `niet` commands.
affects: All versions
gotchaUsing the `-i` or `--in-place` argument will modify the input file directly, replacing its content with the `niet` command's output. This can lead to unintended data loss if not used carefully or without backups.
fix
Always back up files before using `--in-place`, or redirect output to a new file and manually replace the original after verification.
affects: All versions
Errors
Common errors & fixes
niet: command not found
The `niet` executable is not in your system's PATH, or the package was not installed correctly.
fix
Ensure `niet` is installed (`pip install niet`) and that your shell's PATH includes the directory where `pip` installs executables (e.g., `~/.local/bin` on Linux or `Scripts` directory in your Python environment on Windows). You might need to restart your terminal.
ERROR: [Errno 2] No such file or directory: 'non_existent_file.yaml'
The input file specified for `niet` does not exist at the given path.
fix
Verify the file path and name are correct. Use `ls` or `dir` to confirm the file's presence.
ERROR: Unable to parse file, check the format: "Invalid YAML syntax"
The input file (YAML, JSON, or TOML) contains syntax errors and cannot be parsed by `niet`. `niet` exits with a non-zero status code (e.g., 1) in such cases.
fix
Inspect the input file for syntax errors using a linter or validator for YAML, JSON, or TOML. Ensure it conforms to the expected format.
Upgrade
Version history
3.2.0latest on PyPI · released Apr 21, 2023
Audit
Dependencies
pythonrequiredRequired runtime environment.
Agent activity
4 hits · last 30 days
node
4
Resources
niet — pip install niet · libregistry