beam.io.WriteToText 在每个值后添加新行 - 可以删除吗? [英] beam.io.WriteToText add new line after each value - can it be removed?

查看:21
本文介绍了beam.io.WriteToText 在每个值后添加新行 - 可以删除吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的管道类似于以下内容:

My pipeline looks similar to the following:

parDo return list per processed line |  beam.io.WriteToText

beam.io.WriteToText 在每个列表元素之后添加一个新行.如何删除这个新行并用逗号分隔值,以便我能够构建 CSV 文件

beam.io.WriteToText adds a new line after each list element. How can I remove this new line and have the values separated by comma so I will be able to build CSV file

非常感谢任何帮助!谢谢,伊拉兰

Any help is very appreciated! Thanks, eilalan

推荐答案

要删除换行符,可以使用:

To remove the newline char, you can use this:

beam.io.WriteToText(append_trailing_newlines=False)

但是为了在您的值之间添加逗号,TextIO 上没有现成的功能可以转换为 CSV.但是,您可以查看此答案 以获取用户定义的 PTransform,该 PTransform 可应用于您的 PCollection 以便将字典数据转换为.csv 数据.

But for adding commas between your values, there's no out-of-the-box feature on TextIO to convert to CSV. But, you can check this answer for a user defined PTransform that can be applied to your PCollection in order to convert dictionary data into csv data.

这篇关于beam.io.WriteToText 在每个值后添加新行 - 可以删除吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆