How to insert an header row into a .Txt file

I have text file that was created using the Append line within a for each loop. This is my text file

a;23;k;
b;100;C;
c;11;D;

However, I want to add a header to the text file, so it looks like this

$E123;my new cat;B;22AA2;
a;23;k;
b;100;C;
c;11;D;

The use case in Combine txt files keeping 1 header row? did not fully apply to mine. Ideas will be appreciated.

Hi @Yomi_Oluwadara

You can try this

BlankProcess13.zip (40.3 KB)

Hope this helps!!

Hi @Yomi_Oluwadara

str_columns = string.Join(";",yourDatatable.Columns.Cast(Of DataColumn)().Select(Function(column) column.ColumnName).ToArray())

Use write text file or append line activity to write this str_column string to text file before for each

Hope it helps.

@Yomi_Oluwadara

1.Use Read Text File activity and Output variable as **TextFile**
2.Assign: Header= "$E123;my new cat;B;22AA2;"
3.TextFile=Header & Environment.NewLine & TextFile
4.Use Write Text File activity

O/P:

image

@lrtetala it worked! thanks
@supriya117 Thanks !

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.