def load_table_file()

in cloud-functions-looker-actions/write-to-bq-execute/main.py [0:0]


def load_table_file(file_path,table_title):
    client = bigquery.Client()
    table_id = "myproject.mydataset." + table_title # Replace "myproject.mydataset." with your project
    job_config = bigquery.LoadJobConfig(
        source_format=bigquery.SourceFormat.CSV, skip_leading_rows=1, autodetect=True,
    )
    with open(file_path, "rb") as source_file:
        job = client.load_table_from_file(source_file, table_id, job_config=job_config)
    job.result()  # Wait for the job to complete.
    table = client.get_table(table_id)  # Make an API request.
    print(
        "Loaded {} rows and {} columns to {}".format(
            table.num_rows, len(table.schema), table_id
        )
    )
    return "200"