Export Query Results to CSV File

Hi Team,

I need to export my query results to csv format file in cli mode. In CB UI it is present but we want is there anyway possible in cli mode.


Hi @Debasis_Mallick - I would suggest you try out ‘cbshell’: GitHub - couchbaselabs/couchbase-shell: Shell yeah!

@perry Thanks for your response . Adding to above query actually DEV team connecting CB DB through SDK and running their NQL query. Is there any option in SDK available to export to csv format.


Understood, which SDK? It’s likely that there is already support within the language for converting JSON to CSV

To obtain the body of knowledge that everyone throughout history that has ever wanted to convert couchbase to csv : couchbase convert to csv - Google Search

The bottom line is that CSV is only two dimensional, whereas json can b n-dimensional, there is no obvious conversion. You’ll have to make your own.

Google for “converting Json to comma-separated in Java” (without the quotes).

you could also do it in n1ql with "SELECT RAW … " and constructing a single projected property which is a comma-separated string of the properties.

You could also export as json, and pipe that through jq.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.