I am using below code to import and export to CSV. The reason why I am doing an export is because I need all columns in the exported CSV to be enclosed in double quotes. But with below code the double quote is only appearing at the first and last of every line.
Import-Csv c:Emp.csv | Export-Csv c:Emp1.csv -NoTypeInformation -Force
Please note that I have already tried below code (that works but takes longer time if size of CSV is > 200MB):
$inform = Get-Content C:A.csv
$inform | % {
$info = $_.ToString().Replace("|", """|""")
$info += """"
$var = """" + $info
$var | Out-File D:B.csv -Append
}
Sample input (CSV file):
1|A|Test|ABC,PQR
Sample output (CSV file):
"1"|"A"|"Test"|"ABC,PQR"
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…