I have a simple list of items:
['item1', 'item2', 'item3', etc...]
They could belong to a bigger object called product.
I found that the following format work but item are nested under one row.
{'product': ['item1', 'item2', 'item3']}
How can I convert my list to have one item per row in bigquery with a column named product
?
I'm running my code in python in a cloud function.
CodePudding user response:
If what you want to have one item per row in BigQuery:
[{'product': 'item1'}, {'product': 'item2'}, {'product': 'item3'}]
To transform your list of items to a list of products in Python:
items = ['item1', 'item2', 'item3']
products = []
for item in items:
product = {'product': item}
products.append(product)