-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Description
Export-Csv should have option to suppress quotes
By default Export-Csv puts quotes around all fields. This isn't always necessary and some programs even have problems reading the results. For example, Export-Csv will quote a numbers and dates:
…,"227","6/1/2018 12:00:00 AM"
Some programs then interpret the data as strings, which generally isn't the intent.
Also, quotes generally aren't required for strings (unless they contain the delimiter character).
Not using quotes (unless needed) would improve usability with other applications and reduce file output size.
Proposed technical implementation details
A couple options:
- An option -UseQuotes which could be Never, Always, or (optionally) AsNeeded, StringsOnly.
- An option to specify the quote character/string, then I could do -Quote "" to suppress quotes.
- An option -QuoteFields to specify which fields to quote.
Any of these would solve my current problem (all of them would be a complete, powerful solution to most problems).
-UseQuotes options details:
- Never - don't quote anything, ever.
- Always - quote everything (current behavior).
- AsNeeded - only quote fields that need it (they contain a delimiter character).
- StringsOnly - quote all strings, but not numbers, dates, or other non-string values.
There's a good argument to be made that the default behavior should be AsNeeded or StringsOnly as they tend to be more compatible with other applications; however, it would be different and could break existing usage.