【发布时间】:2019-10-17 11:40:19
【问题描述】:
我正在尝试将 Dataframe 加载到 BigQuery 中。我这样做如下:
# Prepare temp file to stream from local file
temp_file = table_name + '-' + str(timestamp_in_ms())
df.to_csv(temp_file, index=None, header=True)
# Define job_config
job_config = bigquery.LoadJobConfig()
job_config.schema = schema
job_config.skip_leading_rows = 1
job_config.source_format = bigquery.SourceFormat.CSV
# Create job to load data into table
with open(temp_file, "r+b") as source_file:
load_job = client.load_table_from_file(source_file, dataset_ref.table(table_name), job_config=job_config)
这在本地开发中运行良好,但是当我部署 Cloud Function 时,它返回以下错误:
OSError: [Errno 30] Read-only file system: '{temp_file}'
这发生在open(temp_file, "r+b") as source_file:一行
为什么无法读取云函数临时存储上的本地文件?出了什么问题?
【问题讨论】:
标签: google-bigquery google-cloud-functions