Is there a way to export the results from BigQuery to a csv file using
bq query "SELECT name,count FROM mydataset.babynames WHERE gender = 'M' ORDER BY count DESC LIMIT 6" command.
I found that we can give --destination_table=mydataset.happyhalloween parameter which will write to a different table. Is there a similar way to write it to a file?
I also tried bq query "SELECT name,count FROM mydataset.babynames WHERE gender = 'M' ORDER BY count DESC LIMIT 6" > output.txt
But this creates additional headers
But I only want results to be written a file
Based on an answer on this thread, I tried the following query, bq query --format=csv "SELECT commit FROM [bigquery-public-data:github_repos.commits] LIMIT 10" > output.txt It was better but I still got some unnecessary text in the file output.txt