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 ![]()

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 ![]()

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.
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 ![]()
Iβve attached a screenshot. Take a look there. No need to use a loop.
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
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.

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:

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

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