对此我还很陌生,我想尝试使用数据流将数据从云存储中的csv数据加载到Bigquery。但是我遇到了以下错误。请建议我做一个更好的方法。在此先感谢>
我正在Linux服务器上运行,python版本是3.x。
AttributeError: 'Client' object has no attribute 'load_table_from_storage'
import argparse
import uuid
import pprint
from google.cloud import bigquery
dataset_name = 'XXX'
table_name = 'XXX'
source = "Input filepath"
format = 'CSV'
def load_data_from_gcs(dataset_name, table_name, source):
bigquery_client = bigquery.Client()
dataset = bigquery_client.dataset(dataset_name)
table = dataset.table(table_name)
job_name = str(uuid.uuid4())
job = bigquery_client.load_table_from_storage(
job_name, table, source)
job.source_format = format
job.begin()
job.result()
print (job.result)
print('Loaded {} rows into {}:{}.'.format(
job.output_rows, dataset_name, table_name))
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('XXX')
parser.add_argument('XXX')
parser.add_argument('CSV')
args = parser.parse_args()
load_data_from_gcs(
args.dataset_name,
args.table_name,
args.source)
load_data_from_gcs(dataset_name, table_name, source)