小编Be2*_*Be2的帖子

将其加载到 bigquery 时如何将具有元数据值的新列添加到 csv

我有一个每日 csv 文件进入 Google 存储上的存储桶,我构建了一个函数来加载该 csv 并将其附加到 BigQuery 中的表中。但是,我想使用该函数向 csv 添加一个新列在将数据加载到大查询之前执行 id (context["id"]) 。

那可能吗?

提前致谢!

def TimeTableToBigQuery(data, context):
    # Getting metadata about the uploaded file, the storage and datetime of insert
    excution_id = context['event_id']
    bucketname = data['bucket']
    filename = data['name']
    timeCreated = data['timeCreated']
    pathtofile = data["id"].rsplit("/", 2)
    # parent_folder = data["id"].rsplit("/", 3)
    file = str(pathtofile[1])
    name = file.split('---')
    dates = name[0].split('_', 1)
    arrivedat = str(dates[1])
    path = pathtofile[0]
    # parent_folder = parent_folder[1]

    # work start here to get the …
Run Code Online (Sandbox Code Playgroud)

python-3.x google-bigquery google-cloud-platform google-cloud-functions

1
推荐指数
1
解决办法
2890
查看次数