ConvertTo-Csv Output without quotes

前端 未结 14 1045
慢半拍i
慢半拍i 2020-12-01 08:03

I am using ConvertTo-Csv to get comma separated output

 get-process | convertto-csv -NoTypeInformation -Delimiter \",\"

It out

14条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-01 08:35

    I found that Kory's answer didn't work for the case where the original string included more than one blank field in a row. I.e. "ABC",,"0" was fine but "ABC",,,"0" wasn't handled properly. It stopped replacing quotes after the ",,,". I fixed it by adding "|(?)" near the end of the first parameter, like this:

    % {$_ -replace  `
        '\G(?^|,)(("(?[^,"]*?)"(?=,|$))|(?".*?(?))', `
        '${start}${output}'}
    

提交回复
热议问题