I have a file data.csv which contains:
2017.11.1,09:55,1.1,1.2,1.3,1.4,1
2017.11.2,09:55,1.5,1.6,1.7,1.8,2
I want to filter it by yesterday date so I did this:
$Data = Import-Csv $file -Header Date,Time,A,B,C,D,E
$CutOff = (Get-Date).AddDays(-1)
$Data2 = $Data | Where-Object {$_.Date -as [datetime] -gt $Cutoff}
$Data2 | Export-Csv -Path "Date2.csv"
But file data2.csv contains:
#TYPE System.Management.Automation.PSCustomObject
"Date","Time","A","B","C","D","E"
"2017.11.2","09:55","1.5","1.6","1.7","1.8","2"
Which is not the same format than the original one:
- How to get rid of double quotes
- How to get rid of the header and type lines