Skip to content

Export-Csv should have option to suppress quotes #8890

@DavidBerg-MSFT

Description

@DavidBerg-MSFT

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:

  1. An option -UseQuotes which could be Never, Always, or (optionally) AsNeeded, StringsOnly.
  2. An option to specify the quote character/string, then I could do -Quote "" to suppress quotes.
  3. 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.

Metadata

Metadata

Assignees

Labels

Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifIssue-Enhancementthe issue is more of a feature request than a bugWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions