Skip to content

Commit

Permalink
trim source CSV cells
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Dec 3, 2024
1 parent a8e1c8c commit 81256c3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/transform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ GSHEET=$(cat gsheet.json)

if echo "$GSHEET" | jq -e .values >/dev/null; then
# save as a CSV
echo "$GSHEET" | jq .values | jq -r '(map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[] | @csv' | tail -n +2 > source.csv
echo "$GSHEET" | jq .values | jq -r '(map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[] | [.[]|rtrimstr("\r")|ltrimstr("\r")|rtrimstr("\n")|ltrimstr("\n")|rtrimstr(" ")|ltrimstr(" ")] | @csv' | tail -n +2 > source.csv
# and also as JSON in a format check my work expects
echo "$GSHEET" | jq -r '.values | map(map(tostring))' > csv.json
else
Expand Down

0 comments on commit 81256c3

Please sign in to comment.