humanbeing
humanbeing

Reputation: 1697

How to export a finished BigQuery Job as a CSV

I know you can run a job and export a csv for an table like under the python example https://developers.google.com/bigquery/exporting-data-from-bigquery

But Is there a way to export a finished query job as a csv if I have the job ID? Ultimately I want the query to display in a table on the browser (already have this working) and also have a button where they can download the file as well.

Cheers

Upvotes: 1

Views: 1308

Answers (1)

Jordan Tigani
Jordan Tigani

Reputation: 26617

If you look up the query job, it will have a destination table specified. If you didn't provide your own table name, this will be a new temporary table created by BigQuery.

You then have two options for getting the results as csv. You can run an export job to export that table as CSV. Or, you can run a tabledata.list() operation on that table and set "alt=csv" which will return the beginning of the table as CSV. Please let me know if you need more detailed instructions.

Upvotes: 4

Related Questions