How to Retain Duplicate columns without bug when reading a CSV

Hi, I am trying to read all the information from a CSV(Using the Read CSV activity) but retain the first row as the column headers but there are duplicates. Because there are duplicates, UiPath will throw an exception if I want to retain all the columns. Any way to work around this but still retain all the columns? ( Even the duplicate ones)

1 Like

@Will.truong09 you can uncheck header properties of read range, then you can get all columns including duplicate columns also but column names will be like column0, column1 etc. Otherthan this there is no workaround for this problem as of I know.

It is a CSV file so I cannot use read range

Hi @Will.truong09

The solution is to micro-manage it a bit.

Use Read CSV file activity with those settings:

You will end up with a Data Table with generic column names that aren’t duplicated plus your column names in the first row.

It is not possible to create a Data Table with multiple columns with the same name, so you will need to act accordingly.
Input file:
image

Output Data Table:
image

Hi,

I would like to implement this solution but am having some trouble. I have a .csv that has duplicate column names. What i want to do is use the “read csv file” activity with the “IncludeColumnNames” disabled so that i can get the generic column names. Then, once its a data table i can update the duplicate column names (which is now just the first row) to something else. Finally, i would like to get rid of the generic column names and have it so that the newly modified first row goes back to being the column names. Obviously my column names are not “Column1, Column2” etc. which is why i would like to retain them. Also, just to note; the two columns that have the same name do not have the same data. Which is why i cannot just get rid of the duplicate column.

Thanks in advance,
Zev

1 Like

Found something… Change datatable header row

1 Like