To Change the position of the first name and the last name in a CSV file

In a particular column in the CSV file called “Name”, contains the first-name and last-name.
But the position are Last-Name First-Name.

I want to interchange it to First-Name Last-Name

Ex: The Name Column has the first entry as
bbb Aaa

where bbb is the last name and Aaa is the first name

Interchange it to Aaa bbb

Thanks in Advance!

1 Like

Hi
—hope these steps would help you resolve this
—use a READ CSV FILE activity and pass the csv file path as input and get the output with a variable of type datatable named dt
—now use a FOR EACH ROW loop and pass the variable dt as input
—inside the loop use assign activity like this

row(“Name”) = Split(row(“Name”).ToString,” “)(1).ToString+” “+ Split(row(“Name”).ToString,” “)(0).ToString

Or

If sometime three words might come in that case use

row(”Name”) = String.Join(“ “,Split(row(“Name”).ToString,” “).AsEnumerable().Skip(1)).Trim+” “+ Split(row(“Name”).ToString,” “)(0).ToString

—then next to this for each row loop use a write csv file activity and pass the dt variable as input

Cheers @ray_sha

1 Like

Hey @Palaniyappan
It works.
Can similar method be used when the first Name and last name are not seperated at all?

Ex: Its like Aaabbb
and you want to convert it into Aaa bbb
Thanks.

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