Convert cqb output to CSV file format

n1ql

#1

Is there a way to convert the output of cbq shell command to a CSV format?

e.g. cbq -q -e http://x.x.x.x:8093 -u “$CBQAdmu” -p “$CBQAdmp” --script “select * from system:completed_requests limit 5” --output test.out

this would generate the output in a jscon format, can we convert this output into a CSV format?

Thanks,
Rajesh


#2

N1QL (cbq shell) outputs into JSON format. You can use external utilities to convert into CSV format
Example: https://stackoverflow.com/questions/28175276/convert-json-to-csv-format


#3

Note that the web-based Query Workbench can export query results in tab-separated format.

On the command-line, a great tool for processing JSON is ‘jq’: https://stedolan.github.io/jq/