Need to remove the duplicate column from excel

Hi Team,

My Excel contains column like below,

District Distict Entity Load Load
Thane Thane 2000 1kg 1kg
Thane Thane 2000 1kg 1kg
Mumbai Mumbai 1000 2kg 2kg
Pune Pune 3000 5Kg 5Kg

Need to remove one of those duplicate column, can anyone explain it how should i achieve it

@Omkar_Deshmukh Please find below thread,

1 Like

Read Range (Add Headers, Unchecked). Remove Column with Index of respective Column. Write Range (Add Headers, Checked). Let us know if the column index is not fixed, well’ll work on another approach.

Regards,
Nithin

2 Likes

Hi @Sugumar8785,

can you please elaborate by considering my column names and what would actually that linq will do?

Sure… @Nithin_P it will help but need to check with column indexing part because Im not sure is that column index is every time same or not… just let me know the approach in case if it is not fixed?

Here is a solution using a function counting the row headers.

Processusvierge.zip (21,2 Ko)

1 Like

hi @Omkar_Deshmukh
in this circumstance , you can use the remove data column activity…
hpy learning :grinning:

@Anthony_Humphries what exactly your checking in below condition?

DtData.Rows(0).ItemArray.Count(Function§ p.ToString = DtData.Rows(0)(ColIx).ToString) > 1

Hello Master :slight_smile:

Its not about just removing column from the excel their is condition based scenarios like “if i found any of column has another duplicate column from same excel sheet then i want to remove the other columns except 1st one” :slight_smile:

Now here is your logic please :wink:

The function checks that the current column header we’re checking matches anything in the row containing the headers. There will always be at least one match, so the Count function will be 1 or higher. If there are duplicates, it will be 2 (or higher if there are multiple duplicates). If there are multiple columns with the same name, delete the current column.

Also, just found a bug in the process. We do not want to increment the index if we delete a column.

Processusvierge.zip (21,2 Ko)

ok cool…but i need very first column in excel if we found any column name with the very first column then i want to delete those column except the very first one.

I’ve updated the workflow to iterate over the data in reverse, so the right-most duplicates are deleted first.

Processusvierge.zip (21,1 Ko)

Im facing some issue while implementing this ?

image

Not sure how bot is taken 3212 a long column number

The process worked with the example input contained in the project I uploaded. If your input is different, please share a copy of the workbook with proprietary data replaced with dummy data so we can address the issue.

dummyReport.xlsx (69.1 KB)

here you go… :slight_smile:

My mistake. The workflow was counting rows; not columns. The updated workflow will work for your report.

Processusvierge.zip (59,7 Ko)