#powershell
$path = "C:\tmp\112.csv"
$data = Import-Csv -Path $Path
$ColNames = ($data[0].psobject.Properties).name
$header = ""
foreach($column in $ColNames)
{
if(![string]::IsNullOrEmpty($header)){
$header = $header + ","
$header = $header + $column
}
else{
$header = $header + $column
}
}
add-content -path $path -value $header
foreach($line in $data)
{
Export-CSV -path $path -InputObject $line -Append -NoTypeInformation
}
# Export-CSV can add quotation by default.
CSV file转成各个字段都加双引号
最新推荐文章于 2023-03-06 14:29:24 发布