How to save an Output DataTable(String Datatype) into CSV File?

How to save an Output DataTable into CSV/Excel ?

Datatype for Output DataTable is String whereas the CSV has a different datatype.
I tried “Write CSV” but it gives an error message:
String cannot be converted to System.Data.DataTable"

2 Likes

You need to convert your string to datatable (using split) and then convert the datatable to csv file?

Let me know if you need further assistance to accomplish this.

In ouput datatable activity you must be using input as datatable.
directly save that datatable using write csv for csv file or write range for excel

Go for the Excel training in the training materials

2 Likes

Hi VVaidya
Thanks for the reply.
Please let me know how can I accomplish this.

Hey @nesachdeva

@nesachdeva Please follow this instruction :slight_smile:

If i am not getting you wrong then are you using “Output datatable activity” to see the output in a string format of a datatable and then trying to write into csv or excel file?

if it is so then instead of output datatable activity output assign datatable directly to the csv/ excel file.
that activity is only to show the output on the console.

still their i am giving an idea to convert the string data into a datatable :slight_smile: by the way.

Here i am attaching a sample workflow which is extracting the string based on “Space” but in your case split on the basis which you wants and here i am using single for-each because i am using counter for demo purpose if you wants column names as well dynamic based on string then use one more for-each and split that as well on the basis of your requirement then add that column and data row into the datatable.

please find the sample workflow to give you an idea.

SampleWorkflow.zip (3.5 KB)

Regards…!!
Aksh

2 Likes

Hi,

Thats what i have tried to do earlier as well.
The problem that I face is, the datatype of the output file (from the output data table) is of the STRING format, whereas in order to save it to a CSV or an excel file, we need to convert the same into DataTable datatype.

Any idea on how to do the conversion? That should help…

Thanks!

i m reading CSV Output ITS showing only 1234 in cell but Exact output shown in Excel or notepad 001234 …how to read exact output in csv .