Forum Discussion
JoyriderBC
Jun 18, 2021Copper Contributor
Powershell is corrupting comma delimited files
My PowerShell script is adding double quotes and formatting the text incorrectly. I am removing lines that have a particular string. This line created by PowerShell script "RECTYPE,CNTBTCH,CNTITEM...
- Jun 28, 2021
JoyriderBC You can specify the encoding of the files with the -Encoding parameter.
For example:
Out-File c:\Exports\'Receiving Export SAGE Zeroes Gone.CSV' -Encoding utf8
farismalaeb
Jun 19, 2021Iron Contributor
Hi,
I try it from my side and its working perfect with no double quote when using the Out-File.
Are you saving the content from a custom PSObject.
I got the double quotes when I replace the Out-File with Export-CSV, and manage to remove it by using PowerShell 7
(get-content C:\Users\1.CSV ) | Export-Csv c:\Fixed.CSV -UseQuotes never
- JoyriderBCJun 24, 2021Copper Contributor
farismalaeb The double quotes are minor problem. It is the record corruption. See the HEX dump where after every character there are unprintable codes.
- farismalaebJun 28, 2021Iron ContributorCan you share part of the output file, just put dump data in it and let me have a closer look.
Thanks