UIPATH - DATATABLE IN TXT

Hello, I would like help to be able to dump a datatable into a TXT file, so that each record of the data table is written to the txt one below the other.

I tried the image but it only saves the last record :frowning_with_open_mouth:

image

Hi @mateo_marquez

Use Append Line acitivty. This will write all your rows one by one.

Or use Read Range Workbook β†’ Output Data Table β†’ Write Text File . This will also work.

But above process will write the entire datatable into a text file.

Regards

It’s because of rewriting.

Try this.
β†’ Convert Datatable into string using Output Datatable activity. Save the data in the string variable.
β†’ Write String variable in the text file.

1 Like

Do I do that inside the for each loop?

Would you show me how to do it with the append line? , I’m a noob :frowning:

I’ve attached a screenshot. Take a look there. No need to use a loop.

Hi @mateo_marquez

The below process will write your entire data table into text file

If you want to write a single column to text file, then do below process, but remember that this will write the data of the column that you give only not entire datatable.

To write the entire datatable please follow the steps of first image.

Regards

2 Likes

This worked for me, but I have to remove the headers, I’m only interested in the information. How would you do it?

Then try a solution that @vrdabberu offered. Solution with append line.
image

Hi @mateo_marquez

If you want to write it to text file without headers use the below syntax in Assign activity:

=> Read Range Workbook
Output β†’ dt

=> Use below syntax in Assign activity
OutputText = String.Join(vbCrLf, dt.AsEnumerable().Select(Function(row) String.Join(vbTab, row.ItemArray)))
OutputText is of DataType System.String

=> Use Write Text file to write OutputText

Input:
image

Output:

Regards

Thank you very much! The solution worked.
The only thing I have a little problem with. I need the TXT to be rewritten with the dt every time the process is executed, otherwise it keeps adding the results below
image

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