multiprocessio / dsq

Commandline tool for running SQL queries against JSON, CSV, Excel, Parquet, and more.
Other
3.71k stars 152 forks source link

Support CSV format output #105

Open AlexZhou1995 opened 1 year ago

AlexZhou1995 commented 1 year ago

dsq output as json format by default. Can we support the output in csv format.

Currently, I need to use the jq and sed to get the output of csv

dsq t1.csv t2.csv "select t1.*,t2.* from {0} t1 join {1} t2 on t1.id = t2.id" | jq -r '(map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[] | @csv' | sed -e 's/"//g' > result.csv

Can we support the output in csv format by --format

dsq --format csv t1.csv t2.csv "select t1.*,t2.* from {0} t1 join {1} t2 on t1.id = t2.id"
labolado commented 1 year ago

dsq *** | dasel -r json -w csv

https://github.com/TomWright/dasel