【发布时间】:2020-09-21 05:46:01
【问题描述】:
当我们在 Apache Beam 中写入文件时,会使用以下类的 header 参数写入文件头
class apache_beam.io.textio.WriteToText(file_path_prefix, file_name_suffix='', append_trailing_newlines=True, num_shards=0, shard_name_template=None, coder=ToStringCoder, compression_type='auto', header=None)
虽然没有开箱即用的页脚,但有人可以提供一种可以将页脚添加到编写的文件的技术吗?
预期的输出是
Header
Row 1
Row 2
..
..
Row 1000000
Footer
【问题讨论】:
-
你看过apache_beam.io.filebasedsink模块吗?文档指出您可能需要调整
open()和/或close()函数来自定义文件处理或写入页眉/页脚。 -
@Peter 该解决方案有效,并且在下面的答案中指出了实现。我们需要覆盖 Sink 并指向自定义编写器中的接收器。
标签: python-3.x google-cloud-dataflow apache-beam