Remove duplicate columns from Data Table in C# and summing up the duplicate column value in original columns

  • Thread starter Thread starter Mohammad Nadeem Alam
  • Start date Start date
M

Mohammad Nadeem Alam

Guest
I have a csv file, which I am loading in C# console application in data table. Please note that this csv file has number of columns more than 100. Csv file is part of process, which comes time to time. There is some mathematical calculation in place using data table. My issue is duplicate columns; this csv each time brings some duplicate columns. My issue is duplicate columns. As we cannot load the csv file with duplicate columns, so at the time of loading csv into data table, whenever i find delicate column, I change the name of the column. Suppose a column named already loaded and again I got a column named d, so I rename it duplicate, so that I can load it. Same way whenever I got duplicate columns, I do the same. So may be in 100 columns, three columns is duplicated. Now my requirement is to remove the duplicate columns and in original column value of each cell will be value of sum the value of original +duplicate columns respective to each cell. Value of each cell may be positive or negative.

Like below example


a


b


c


d


e


f


d_duplicate


g


h


e_duplicate


80


30


40


10


5


4


2


40


0


-5


20


10


25


20


10


8


4


25


2


-10


30


20


30


30


15


12


6


30


6


-15


40


40


45


40


20


10


8


45


8


-20


40


60


60


50


25


20


10


60


1


-25


60


80


80


60


30


24


12


80


2


-30


70


90


10


70


40


28


14


10


3


-40


80


20


20


80


45


32


16


20


5


-45


90


10


30


90


50


36


18


30


6


-50


Mohammad Nadeem Alam SME in Emirates NBD

Continue reading...
 
Back
Top