Can text written by append line be overritten?

Hello,
I’m using the “Append Line” activity within a “For Each Row in DT” to write a text. and this works fine because all row data are written as expected.

However, after each run, “Append Line” activity adds to the text file. For example;
first run : 5 rows are written to text
second run : the same 5 rows are written to the same text file ( now making it 10)

For each run, I want the content of the previous run overwritten, how can this be achieved?

other activities like "write Line only write the last row which is not what I wanted.

@Yomi_Oluwadara

At the start of each run either delete the previous file so that the file is new again

Or

You can use write text file for the first iteration and then use append

Cheers

1 Like

@Anil_G is there a delete text activity that I can use?

Hi @Yomi_Oluwadara,

Maybe you would require to use the Write Text File activity, instead of the Append Line, as the Data present in the file is to be overwritten, each time it is executed, the new data is added removing the previous data.

@Yomi_Oluwadara

There is no delete line

If you use write it will delete

Cheers

@supermanPunch and @Anil_G only write a single data row despite been in a for each. This is not the behavior I wanted

@Yomi_Oluwadara

If in for loop…then for loop has a index variable…use a if condition with condition as index=0

On then then side use write line and on else side use append line

This should solve the issue

Or before for loop use delete file and delete the file if exists

Cheers

1 Like

Deleting it prior worked. Thanks!

1 Like

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