Given a comma separated plain text file import-week10.csv file, I'd like to change the header, to fix a duplicate column name issue. The "corrected" header would be available in another file correct.csv (the only row there). File import-week10.csv would then be saved (overwritten) with this new header.
Example first row in the file:
ID,name,surname,DOB,name,surname,DOB,amount
or
ID,"name","surname","DOB",name,surname,DOB,amount
should become, with unique column names:
ID,"name main","surname main","DOB main","name joint","surname joint","DOB joint",amount
First question, how do I script this change with Powershell ?
Second question, I would like to compare and get a warning: if this first row has changed in import-week10.csv, from last week's file import-week09.csv. Assuming new columns will be added, or changed, every couple weeks.
Environment: WS 2012 R2, could update to latest PS version if need be.