dasel
"Select, put and delete data from JSON, TOML, YAML, XML and CSV files with a single tool. Supports conversion between formats and can be used as a Go package." - https://github.com/TomWright/dasel
Example usage
Restructure a pagerduty csv
Download the csv using this shell function that uses BSD (macOS) date
and open
:
pagerduty-csv-download() {
TZ=America/Los_Angeles
past="$(date -v-7d "+%FT%T")"
present="$(date "+%FT%T")"
open "$(date "+https://company-name.pagerduty.com/api/v1/reports/raw/incidents.csv?since=${past}&until=${present}&time_zone=${TZ}")"
}
Then restructure it using --format
to interpolate variables into a template string:
dasel -f incidents.csv -w json -m --format '{{ .created_on }} https://company-name.pagerduty.com/incidents/{{ .id }} {{ .description }}' '.[*]'
The output will be something like:
2022-02-02T20:02:02-08:00 https://company-name.pagerduty.com/incidents/Q0ZL9NU2 [FIRING:1] TargetDown (cat-downloader)
Pretty format a gpx file
This is useful for comparing two files, for instance where one may have been appended, and you need to make sure.
dasel -r xml -f 2022-01-02-18-20-00.gpx > old.gpx
Keep in mind though that pretty-formatted gpx files take up significantly more space. dasel
does not appear capable of compact -c
formatting xml, though there is an issue requesting it.