Skip to content

Commit a526c62

Browse files
committed
Added export format option
1 parent d2818ba commit a526c62

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

bigquery/samples/export_data_to_cloud_storage.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# [START export_table]
2121
def export_table(service, cloud_storage_path,
2222
projectId, datasetId, tableId,
23+
export_format="CSV",
2324
num_retries=5):
2425
"""
2526
Starts an export job
@@ -30,6 +31,8 @@ def export_table(service, cloud_storage_path,
3031
cloud_storage_path: fully qualified
3132
path to a Google Cloud Storage location,
3233
e.g. gs://mybucket/myfolder/
34+
export_format: format to export in;
35+
"CSV", "NEWLINE_DELIMITED_JSON", or "AVRO".
3336
3437
Returns: an extract job resource representing the
3538
job, see https://cloud.google.com/bigquery/docs/reference/v2/jobs
@@ -49,6 +52,7 @@ def export_table(service, cloud_storage_path,
4952
'tableId': tableId,
5053
},
5154
'destinationUris': [cloud_storage_path],
55+
'destinationFormat': export_format
5256
}
5357
}
5458
}

0 commit comments

Comments
 (0)