beam.io.WriteToText add new line after each value - can it be removed?

假装没事ソ 提交于 2021-01-29 10:23:39

问题


My pipeline looks similar to the following:

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

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


回答1:


To remove the newline char, you can use this:

beam.io.WriteToText(append_trailing_newlines=False)

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.



来源:https://stackoverflow.com/questions/50913942/beam-io-writetotext-add-new-line-after-each-value-can-it-be-removed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!