beam.io.WriteToText 在每个值后添加新行

编程入门 行业动态 更新时间:2024-10-22 08:42:40
本文介绍了beam.io.WriteToText 在每个值后添加新行 - 可以删除吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

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

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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-19 22:59:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/971388.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:在每个   beam   io   WriteToText

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!