I have a problem with a script where Excel saves the file as CSV.
The delimiter is always “,”, when in fact in my windows system settings the delimiter is set to “;”.
When I normally save the file in Excel as CSV, it will have the delimiter as it should, which is “;”, however in Powershell it doesn’t seem to take that into account and always saves with “,” delimiter.
Is there a way to override it with the correct delimiter?
You’re using file format 6 which is generic CSV
have you tried format 23 which is Windows CSV. That may pick up your default Windows settings
see https://msdn.microsoft.com/EN-US/Library/ff198017.aspx for file format info
I tried setting the format to 23 and still didn’t change anything.
I actually ran the following code to get the currently used list separator info:
(Get-Culture).TextInfo.ListSeparator
Which strikes me as odd, is that Powershell claims the list separator to be “,”, while in Windows region settings I’ve set it to “;”.
I can’t reproduce this. Both the Get-Culture command and Excel are behaving fine on my system, using your code as-is. The only thing I’ve noticed is that if I change those settings in the control panel, they don’t take effect until the next time I start PowerShell (or Excel).
I finally resolved the issue and it was quite simple: restart the system after applying list separator changes in Windows region settings :).
At first I preferred not to restart the server, as there were other important background services running, but I was left with no other choice. Happy it helped.