I have a script I am trying to read a csv file with and assign column names to the data. however the files has multiple columns named the same see below Grade QA/QC and Symbol
ID,Date,Water Level / Niveau d'eau (m),Grade,Symbol / Symbole,QA/QC,Discharge / Débit (cms),Grade,Symbol / Symbole,QA/QC
07QC008,2018-12-28T00:00:00-06:00,6.536,,,1,0.052,,,1
here is the code below, how can I modify it to maybe strip out the header row and susbstitute my ow columns names?
$stations = import-csv “C:\Users\robm\Downloads\stations\SK_hourly_hydrometric.csv”
#$stations | Get-Member
ForEach ($station in $stations){
$ID = $($station.ID)
$Date = $($station.Date)
$WaterLevel = $($station."Water Level / Niveau d'eau (m)")
$GradeWL = $($station.Grade1)
$SymbolWL=$($station."Symbol / Symbole1")
$QAWL=$($station."QA/QC1")
#$Discharge=$($station."Discharge / Débit (cms)")
$Discharge=$($station."Discharge")
$GradeD=$($station.Grade2)
$SymbolG=$($station."Symbol / Symbole2")
$QAD=$($station."QA/QC2")
Write-host $ID "|" $Date "|" $WaterLevel "|" $GradeWL "|" $SymbolWL "|" $QAWL "|" $Discharge "|" $GradeD "|" $SymbolG "|" $QAD
#Write-host $Discharge
}
Import-CSV
cmdlet has a-Header
parameter that allows one to specify the desired column names.