Export-Csv - why is PowerShell adding delimiter "" - how to avoid this

Export-Csv - why is PowerShell adding delimiter ""

Export-Csv -Path $CSVFile -Encoding UTF8 –delimiter ";" -NoTypeInformation

I have a csv file with this content (before Export)

24/07/2018 05:36;Create;02/11/2019 00:00;flastnamei;firstname;lastname;Stagiaire;SI;Job Coaching Bruxelles;FALSE;FALSE;TRUE;FALSE;TRUE;FALSE;FALSE;TRUE;;;

when i use the command

Export-Csv -Path $CSVFile -Encoding UTF8 –delimiter ";" -NoTypeInformation
the file is changed like this

"24/07/2018 05:36";"Create";"02/11/2019 00:00";"flastname";"firstname";"lastname";"Stagiaire";"SI";"Job Coaching Bruxelles";"FALSE";"FALSE";"TRUE";"FALSE";"TRUE";"FALSE";"FALSE";"TRUE";;"";""

"" are added which is really annoying….

why ???
François VDCIcT service DeskAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AlexProject Systems EngineerCommented:


Export-Csv -Path $CSVFile -NoTypeInformation

Open in new window

Don't stipulate the delimiter or the encoding and see how you get on. If that doesn't work, use UNICODE and not UTF.
It's not adding a delimiter; it's adding quotes around the fields, because it's the safest way to export. What happens otherwise if one of the fields contains the delimiter in the text?
If you are absolutely, one hundred percent, sure that the delimiter is not and will never show up in any of the fields, you canuse this as workaround to replace the Export-Csv command:
... | ConvertTo-Csv -Delimiter ';' -NoTypeInformation |
	ForEach-Object {$_.Trim('"').Replace('";"', ';')} |
	Set-Content -Path $CSVFile -Encoding UTF8

Open in new window

To clarify that: the cmdlet is not generating (with ; as delimiter, spaces inserted for clarity)
field1  ";"  field2  ";"  field3

Open in new window

It is generating
"field1"  ;  "field2"  ;  "field3"

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
François VDCIcT service DeskAuthor Commented:
tks. strange that at the beginning the file was not containing the ""
Anyway, I'm happy with this now that I understand
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.