Swapping the columns

Hi,

I have to swap two columns in CSV file. Can anyone help me on this ?

Thank you

HI @divyaag

you can use Read CSV and have a datatable output that you can perform any kind of operation on it,

my question is what’s the task you are trying to accomplish?

do you simply want to read a CSV and then save it with swapped columns?

Once you have the DataTable in memory, you can use the SetOrdinal method to change the order of the columns, via the Invoke Method activity.

Then you can save back to a CSV file.
Here is the workflow that swaps two column in a data table, in memory. Main.xaml (8.7 KB)

Regards
Silviu

2 Likes

Hi @reda,

Yes , I just want to swap the data and resave the file.

Thank you

Hi @Silviu,

am getting Invoke method : Value cannot be null .

Cna you please guide here Main (1).xaml (7.3 KB)

HI @Silviu

it worked now… thank you

Hi @Silviu ,

am again getting value cannot be null error . Can you please help Main.xaml (7.8 KB)

Thank you

Hi @divyaag,

I checked the workflow you uploaded and looks good. Maybe the error comes from a mismatch between the column name in the CSV file and the name specified in the workflow - “Record ID”. Check if you have a column with exactly that name in the input file.

Regards
Silviu