I've been stuck in streaming insert .Json data into BigQuery but Null:[] in .json data causes error like this .
I googled and added some parameters on csv.DictReader parameters but Null data are still there.
Could you teach me how to remove Null: data in .Json . Thank you so much .
def stream_data():
# BigQuery
client = bigquery.Client()
project_id = 'test_project'
dataset_name = 'test'
table_name = "test"
full_table_name = dataset_name + '.' + table_name
json_rows = []
with open('./test.csv','r') as f:
for line in csv.DictReader(f,skipinitialspace=False,quoting=csv.QUOTE_NONE):
line_json = dict(line)
json_rows.append(line_json)
errors = client.insert_rows_json(
full_table_name,json_rows,row_ids=[row['luid'] for row in json_rows]
) //stop making record that has same luid duplicately
if errors == []:
print("New rows have been added.")
else:
print("Encountered errors while inserting rows: {}".format(errors))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…