【发布时间】:2023-03-06 17:17:01
【问题描述】:
我在 GCS 中有一个包含 JSON 文件列表的存储桶。我来提取文件名列表使用
def list_blobs(bucket_name):
storage_client = storage.Client()
blobs = storage_client.list_blobs(bucket_name)
json_paths = []
for blob in blobs:
json_paths.append(f"gs://{bucket_name}/{blob.name}")
return json_paths
现在我想将此文件名列表传递给 apache Beam 以读取它们。我写了这段代码,但它似乎不是一个好的模式
for i,file in enumerate(list_files):
print("parsing file:", file)
concat_data = (p |'Data {}'.format(i) >> ReadFromText(file)
)
final_result.append(concat_data)
你以前遇到过同样的问题吗?
【问题讨论】:
-
您检查过 ReadAll 转换吗?
-
@Iñigo 你能看一下我对 Batra 先生回答的回复吗
标签: python google-cloud-dataflow apache-beam