<jupyter_start><jupyter_text>BigQuery all datasets to storage<jupyter_code>from utils.bq_dataset_to_storage import bq_dataset_to_storage
from google.cloud import bigquery

# Construct a BigQuery client object.
client = bigquery.Client()

# TODO(developer): Set dataset_id to the ID of the dataset that contains
#                  the tables you are listing.
dataset_id = 'bigquery-public-data.crypto_bitcoin'

tables = client.list_tables(dataset_id)  # Make an API request.
print("Tables contained in '{}':".format(dataset_id))
for table in tables:
    query = "select * from `{}.{}.{}`".format(table.project, table.dataset_id, table.table_id)
    print(query)
    dataframe = (
        bqclient.query(QUERY)
        .result()
        .to_dataframe(
            create_bqstorage_client=True,
        )
    )
    
    filename = "{}/{}-{}.csv".format(BUCKET_URI, table.dataset_id, table.table_id)
    dataframe.to_csv(filename)    
# Test function
bucket_name = 'data-science-on-gcp-323609-test'
dataset_id = 'data-science-on-gcp-323609.test'
bq_dataset_to_storage(bucket_name, dataset_id)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11538461538461539, 'fraction_numerical': 0.01073345259391771, 'mean_word_length': 3.9078947368421053, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '394641', 'license': 'MIT', 'n_tokens_mistral': 382, 'n_tokens_neox': 374, 'n_words': 76, 'path': 'bq-dataset-to-storage.ipynb', 'repo_name': 'matthh9797/blockchain-exploration', 'size': '1118'}