From 4c2fbba2a974dcc942e7c2e5546b1ebfefa3e3d5 Mon Sep 17 00:00:00 2001 From: Erik Thorelli Date: Tue, 5 Nov 2024 12:27:21 -0800 Subject: [PATCH] Update exporting.md jq script to make cleaner CSVs The jq script to create a CSV that includes the labels was losing the formatting (each item just became a cell instead of sticking to a single column). --- docs/using/exporting.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/using/exporting.md b/docs/using/exporting.md index 3e995711..a897e200 100644 --- a/docs/using/exporting.md +++ b/docs/using/exporting.md @@ -29,14 +29,14 @@ The archive will contain a few items: You can use the `jq` tool to convert the JSON files to CSV: -To create a single column CSV with all your urls, in the directory with your json files: +To create a single column CSV (`output.csv`) with all your urls, in the directory with your json files: ``` -jq -r '.[].url' *.json +jq -r '.[].url' *.json > output.csv ``` -To create a CSV that also contains your labels, you can use this command: +To create a CSV (`output.csv`) that also contains your labels in a second column, you can use this command: ``` -jq -r '[.[] | {url: .url, labels: (.labels | join(","))} | "\(.url),\"\(.labels)\""] | @csv' *.json +jq -r '.[] | [.url, (.labels | join(","))] | @csv' *.json > output.csv ```