google-big-queryHow do I use Google Big Query to zip files?
Google BigQuery does not natively support zipping files. To use BigQuery to zip files, you will need to export the files to Google Cloud Storage, then use the gsutil command line tool to zip the files.
The following example code will export the file named my_file.csv
from BigQuery to Google Cloud Storage, then zip the file:
bq extract --destination_format=CSV 'my-project:my-dataset.my_table' gs://my-bucket/my_file.csv
gsutil cp gs://my-bucket/my_file.csv gs://my-bucket/my_file.zip
This code will create a zip file named my_file.zip
in the Google Cloud Storage bucket my-bucket
.
The code consists of two parts:
bq extract
: This command will export the tablemy-project:my-dataset.my_table
from BigQuery to the filemy_file.csv
in the Google Cloud Storage bucketmy-bucket
.gsutil cp
: This command will copy the filemy_file.csv
from the Google Cloud Storage bucketmy-bucket
to the filemy_file.zip
in the same bucket.
For more information about the bq extract
and gsutil cp
commands, see the following links:
More of Google Big Query
- How can I use the CASE WHEN statement in Google Big Query?
- How can I use Google BigQuery ML to build a machine learning model?
- How can I use Google BigQuery to wait for a query to complete?
- How can I use Google BigQuery to retrieve data from a specific year?
- How do I create and use a user-defined function (UDF) in Google BigQuery?
- How can I use Google Big Query with PHP?
- How can I take a course on Google Big Query?
- How can I use Google Big Query to count the number of zeros in a given dataset?
- How can I use Google BigQuery to analyze Bitcoin data?
- How can I create a Google BigQuery table?
See more codes...