在Powershell中使用export-csv时如何避免双引号

时间:2017-11-03 11:01:58

标签: powershell csv

我有一个文件data.csv,其中包含:

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

我想在昨天的日期过滤它,所以我这样做了:

$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"

但是文件data2.csv包含:

#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"

其格式与原始格式不同:

  • 如何摆脱双引号
  • 如何摆脱标题和输入行

0 个答案:

没有答案