首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将分析过的TextFiles与Apache中的DataFlow结合起来?

如何将分析过的TextFiles与Apache中的DataFlow结合起来?
EN

Stack Overflow用户
提问于 2020-02-05 16:55:20
回答 1查看 655关注 0票数 2

这在DirectRunner中似乎很好,但是当我切换到DataflowRunner时出错。我基本上需要以某种方式将读取的文件组合在一起,但是一旦我使用beam.combiners.ToList()连接数据,它就会带来一系列问题。

代码示例:

代码语言:javascript
复制
def convert_to_dataframe(readable_file):
    yield pd.read_csv(io.TextIOWrapper(readable_file.open()))

class merge_dataframes(beam.DoFn):
    def process(self, element):
        yield pd.concat(element).reset_index(drop=True)

    with beam.Pipeline(options=pipeline_options) as p:

        (p
            | 'Match Files From GCS' >> beam.io.fileio.MatchFiles(raw_data_path)
            | 'Read Files' >> beam.io.fileio.ReadMatches()
            | 'Shuffle' >> beam.Reshuffle()
            | 'Create DataFrames' >> beam.FlatMap(convert_to_dataframe)
            | 'Combine To List' >> beam.combiners.ToList()
            | 'Merge DataFrames' >> beam.ParDo(merge_dataframes())
            | 'Apply Transformations' >> beam.ParDo(ApplyPipeline(creds_path=args.creds_path,
                                                                  project_name=args.project_name,
                                                                  feature_group_name=args.feature_group_name
                                                                  ))
            | 'Write To GCS' >> beam.io.WriteToText(feature_data_path,
                                                    file_name_suffix='.csv',
                                                    shard_name_template='')
         )

错误:

代码语言:javascript
复制
"No objects to concatenate [while running 'Merge DataFrames']" 

我不理解这个错误,因为“组合到列表”的部分应该生成一个数据文件列表,然后传递到“Merge”步骤中,这是我使用DirectRunner时的情况。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-02-13 23:40:28

考虑到这个错误,我怀疑MatchFiles实际上没有匹配任何东西(例如,由于一个坏的文件模式),因此,beam.combiners.ToList的输出是一个空列表。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60080589

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档