python - ETL 从谷歌云存储加载到 biquery
问题描述
我想从谷歌云存储上的数百个 CSV 文件中加载数据,并每天使用云数据流(最好使用 python SDK)将它们附加到 Bigquery 上的单个表中。你能告诉我我怎么能做到这一点吗?
谢谢
解决方案
我们也可以通过 Python 来实现。请找到以下代码片段。
def format_output_json(element):
"""
:param element: is the row data in the csv
:return: a dictionary with key as column name and value as real data in a row of the csv.
:row_indices: I have hard-coded here, but can get it at the run time.
"""
row_indices = ['time_stamp', 'product_name', 'units_sold', 'retail_price']
row_data = element.split(',')
dict1 = dict()
for i in range(len(row_data)):
dict1[row_indices[i]] = row_data[i]
return [dict1]
推荐阅读
- python-3.x - 我无法检索 Table_Service 的 query_entities 的属性
- javascript - 如何在编写序列化 json 时防止删除空格
- objective-c - NSPredicate predicateWithFormat @"ANY relationship.attribute == %@" 抛出异常
- scala - 如何使用 Spark Windowing 根据条件查找数据帧的第一行和第 n 行之间的差异
- java - 用于匹配 XML 节点的正则表达式
- angular - 如何避免在表格标题内单击会触发单击整个表格标题
- java - 如何实现参数相同但签名不同的方法
- amazon-s3 - 如何将我的文件从 s3 加载到 powerBi?
- c - 指向函数和状态机的通用指针
- angular - Three.js 和 Angular 6 不从 JSON 文件渲染对象