How to write data stored in a variable to csv file?


I have extracted data from one CVS file and made some modification (data manipulation) and stored in a variable.

Now i want to have that data coming in the variable to get stored in another CVS file.

sequence is something like this

first read csv file —> using assign property to filter some data using select method —> build data table to create row → for each there data manipulation is taking place —> write csv to again store data

attaching xaml file as well NickName.xaml (9.2 KB)

You can try generate datatable activity to build your datatable, then filter the data / columns required to then a new CSV.

You can use the below approach:

  1. Read csv file
  2. Use Filter Datatable activity . it will return the datatable
  3. Write in csv file

Thanks Jyotika.

But i donot want to filter from previos csv file.

I have few names and whether there are member of the organisation

then from that data using string functions
i have created new usernames for all users.

now i want to write the username along with the person into new csv file

thank u

Thank u

So you already filter the DT using the DT.Select Statement

If you just want to then take those into a new datatable you dont need for each to build need datatable.

If your excel spreadsheet has the headers of Name, Username then you cna do the below.

within your write CSV activity add the filepath where you want it to be created.
In the datatable column add DT.Select().CopytoDatatable.DefaultView.ToTable(True, "Name", "Username")
Also check add headers.


Thanks Tim.

using Write CSV activity

i can just provide the path where i want to create the csv file
the the name of the data table.

where to write this DT.Select().CopytoDatatable.DefaultView.ToTable(True, “Name”, “Username”)

in build data table activity??

I have Added the Add row activity in workflow. please check it
NickName (1).xaml (9.5 KB)

Ya. No Syntax Error.

now with this we are adding row in data table.
but on debugging it is giving error.
Actually i have created new username using few string function but it is giving error. expected int

inside the Write CSV activity where is states Datatable

No need for Build datatable activity.

Tried that. Not working

and xaml file as well

NickName (1).xaml (7.9 KB)

check the datatype of column username in build data table should be string.

1 Like

Check the update project file.
NickName (1).xaml (10.2 KB)

1 Like

Thanks .

Sorry forgot to change column 2 to string .
it was in integer

Its working now

Name_DataTable.Select("[Club Member]= ‘Yes’ ").CopyToDataTable.DefaultView.ToTable(True,“Name”,“Username”)

That is what you want to use. You had to take your statement and put it in the statement i provided to you. :stuck_out_tongue_winking_eye:

Thanks TIm :stuck_out_tongue:
I will keep that in mind from next time :smiley:

1 Like

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