我需要将记录插入BIGQUERY表中,其中一列的值为双引号(")。 到目前为止我无法这样做。我已经阅读了一些文档,建议将引号字符更改为 在BigQuery表中加载(")的其他东西。但我仍然无法弄清楚如何做到这一点。 感谢这方面的任何帮助。
请在下面找到我一直在使用的插入代码:
bigquery_client = bigquery.Client(project = 'financelcr')
dataset = bigquery_client.dataset('Dataset1')
table = dataset.table('Sample_Table')
# Here, one of the variable value is " which is resulting in error in json creation.
var = '["' + table_uuid + '","' + file_type + '","' + Reporting_Date + '","' + Created + '","' + field + '","' + Dictionary[field] + '","' + Datatype + '"]'
try:
data = json.loads(var)
print ("json created")
except:
print("Error in getting Dataset/table name Or Error in json creation")
else:
table.reload()
rows = [data]
errors = table.insert_data(rows)
if not errors:
print('Loaded 1 row into {}:{}'.format(dataset, table))
else:
print('Error while Inserting records')