Buy Me a Coffee? Your support is much appreciated!
Source Code:
import time
from google.cloud import bigquery
client = bigquery.Client()
job_config = bigquery.LoadJobConfig(
source_format=bigquery.SourceFormat.CSV,
skip_leading_rows=1,
autodetect=True,
)
table_id = "sql-for-bigquery.JJ.SF_Air_Traffic_Passenger_Statistics"
with open(r'SF_Air_Traffic_Passenger_Statistics.csv', "rb") as source_file:
job = client.load_table_from_file(source_file, table_id, job_config=job_config)
while job.state != 'DONE':
time.sleep(2)
job.reload()
print(job.state)
print(job.result())
table = client.get_table(table_id)
print(
"Loaded {} rows and {} columns to {}".format(
table.num_rows, len(table.schema), table_id
)
)
