Two columns having the same column name in a csv file

Hi All

I have to process a csv file which has two columns with same column name. It will give error in Read CSV. So i am planning to rename one column then process the file and again rename back to the original.

I can rename by just doing Write Cell but the cell may change in future. So I thought Ctrl+f will do. Could you suggest what would be the best way for the same ?

You can search for the second occurrence of the cell with same name and can change it.

Hi @kkpatel,

If the column index doesn’t change you can also input information by it. For example, let’s say column 1 and column 2 have the same name by using index of the column it won’t confuse the bot.

example:

row(ColumnIndex) = “burrito”

Happy Automation! :grin:

1 Like

Hi @kkpatel ,

Were you able to change the column name in csv file?

Regards,
Ashish Manjrekar

how ?

a csv is just a regular text file that is specially ordered such that every “value” is separated by a comma, and every row represents a new row of data. The first row is always the headers.

So if your .csv file has duplicate column names, you should read text file (save as string variable), then you can use a strings.split() method to split by comma. Then you can use linq or something similar to find duplicate column names and change them. Once changed you can overwrite the .csv and use read range like normal