Outputting headers on CSV files using Google Cloud Dataflow
Caio Iglesias
11

The TextIO.Write in Dataflow now has withHeader function to add a header row to the data. This function was added in verison 1.7.0.

So you can add a header to your csv like this:

TextIO.Write.named("WriteToText")
.to("/path/to/the/file")
.withHeader("col_name1,col_name2,col_name3,col_name4")
.withSuffix(".csv"));

The withHeader function automatically adds a newline character at the end of the header row.