application_vnd.jupyter.stderr_output_1.png
from google.cloud import bigquery

import os

import numpy as np
import pandas as pd
import os

PROJECT_ID = 'YOUR_OWN_PROJECT_ID'
from google.cloud import bigquery
client = bigquery.Client(project=PROJECT_ID, location='US')

path = '../input/'
dataset_id = 'titanic'
dataset_ref = client.dataset(dataset_id)
job_config = bigquery.LoadJobConfig()
job_config.source_format = bigquery.SourceFormat.CSV
job_config.skip_leading_rows = 1
job_config.autodetect = True

existing_datasets = [dataset.dataset_id for dataset in client.list_datasets()]
if not dataset_id in existing_datasets:
    client.create_dataset(dataset_id)

dataset_ref = client.dataset(dataset_id)

existing_tables = [table.table_id for table in client.list_tables(dataset_id)]
for filename in os.listdir(path):
    print(path + filename)
    table_id = filename.rstrip('.csv')
    if not table_id in existing_tables:
        table_ref = dataset_ref.table(table_id)
        with open(path + filename, 'rb') as source_file:
            job = client.load_table_from_file(source_file, table_ref, job_config=job_config)
        job.result()