Closed scotthardwick closed 11 months ago
@scotthardwick can you please add some formatting to your post? As it is, it's very much a block of text and quite hard to read.
Thanks! 😊
@vexx32 Thanks for the suggestion. I have gone in and done some formatting. Hope that helps!
I don't think it is a good idea to add (common) parameters like -Last
, -First
, -Skip
and -SkipLast
to just these two cmdlets. Instead:
Select-Object
cmdlet should be used.Or:
csv
cmdlets , any other cmdlet that supports an -InputObject
parameter via the pipeline comes in play. Meaning that it should be considered to add them to the CommonParameters. See: #12164OMG YES please. I would have loved me some escape char support the past few days.
-UseQuotes
What python doesn't have and would be nice to have would be to distinguish between empty strings and $null, by quoting one but not the other. Why? Because an empty response is not the same thing as no response at all.
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.
(If I need to break this feature request up into a multiple, I can do so. Wasn't sure if I should break it based on Import/Export, or to post one per new parameter suggestion. In the end I have bundled all these suggestions together.)
As the programmers work towards PowerShell 7's final release, I wanted to suggest perhaps we strengthen some of the options that are available in PowerShell's CSV cmdlets (Import-CSV, Export-CSV, ConvertTo-CSV, ConvertFrom-CSV).
I can't speak for every programmer everywhere, but as an admin scripter working with legacy systems, I find I do a lot of processing on CSV files that are batch created and dumped somewhere for me. While PowerShell has a good few features, I still find myself pre-processing the file and then post fixing the object. Below are some suggestions that might make it easier for CSV users. I don't think any of these should be controversial and none of this should break existing code.
PowerShell's code for CSV operations seems to be based around: src/Microsoft.PowerShell.Commands.Utility/commands/utility/CsvCommands.cs
Import
-Header <String[]>
-Delimiter <Char>
Defaults to (Get-Culture).TextInfo.ListSeparator(NEW)
-EscapeChar <Char>
Allow user to define the Escape Character. Defaults to " keeping backward compatibility.(NEW)
-QuoteChar <Char>
Allow user to define the Quote Character. Defaults to " keeping backward compatibility.(NEW) for "//" )
-CommentChar <Char>
Allow user to define the Comment Character. Defaults to # keeping backward compatibility. (Note: I see some commented with // so wasn't sure if this parameter should be CommentStr(NEW)
-Strict
Indicates to raise an error when the number of fields is different from that of the header record.(NEW)
-First <Int32>
Specifies the number of lines at the beginning of a data file to parse after the header (if avail) and after skip (if specified)(NEW)
-Last <Int32>
Specifies the number of lines at the end of a data file to parse after skiplast (if specified)(NEW)
-Skip <Int32>
Specifies the number of lines at the beginning of a data file that the parser should skip over after the header (if avail)(NEW)
-SkipLast <Int32>
Specifies the number of lines at the end of a data file that the parser should skip over(NEW)
-Trim <TrimKind>
Specifies if PowerShell should trim spaces before placing the content into the object. Default is None for backward compatibility. Options of None/Trim/InsideQuotes(NEW)
-NoHeaderSpaces
Remove spaces from any header name in the object property name.(NEW)
-ColumnTypes
(See #11942) Specifies the Type of the specified columns. Columns not specified default to [string]. This could be implemented in multiple ways and I am not sure what would be best. The parameter may also be better named something like TypeMap. One possible way to do this would be:-ColumnTypes @{Age='Int';Birthday=[DateTime]}
Export
(NEW)
-Header <String[]>
Allow user to define the outgoing header of the file.-Delimiter <Char>
Defaults to "," and oddly not (Get-Culture).TextInfo.ListSeparator. Changing this would be a breaking change.So just leave alone.(NEW)
-EscapeChar <Char>
Allow user to define the Escape Character. Defaults to " keeping backward compatibility.(NEW)
-QuoteChar <Char>
Allow user to define the Quote Character. Defaults to " keeping backward compatibility.-UseQuotes <QuoteKind>
ie, Never/Always/AsNeeded-QuoteFields <String[]>
ex. "DateTime", "Date"(NEW)
-Trim <TrimKind>
Specifies if PowerShell should trim spaces before exporting the content. Default is None for backward compatibility. Options of None/Trim