GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — No longer skips a column without name if double quote delimiter is used in Import-Csv by Topping · Pull Request #7899 · PowerShell/PowerShell Conversation
| ||||||||||||||||||||||||||||||||
| @@ -0,0 +1,2 @@ | |||
| a1""a3 | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Would prefer to generate these at runtime than have it checked in as it's easier to see the test file in the test code than open another file. Something like:
$emptyValueCsv = @' a1""a3 v1"v2"v3 '@ Set-Content testdrive:/EmptyValue.csv -Value $emptyValueCsv
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I looked into using a here-string earlier, but the lack of indentation for the string terminator made the code look quite messy.
I couldn't quite find an elegant way to add the here-string, but I've gone an added one for the different file contents.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
|
|
||
| It "Should handle <name>" -TestCases @( | ||
| @{ name = "quote with empty value"; expectedHeader = "a1,H1,a3"; file = $TestImportCsvQuoteDelimiter_EmptyValue; delimiter = '"' } |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This formatting seems off, lines 33-38 have one extra indentation. Also, it's nice to align the semicolons in the hashtable per row to make them easier to read
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Turns out those lines had tabs as indentation, instead of spaces like the rest of the lines.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Content for double quote delimiter test moved inside the test file.
Indented test file content for double quote tests
Few lines in import-csv.tests had tabs for indentation instead of spaces.
There was an error while loading. Please reload this page.
| @{ name = "value enclosed in quote" ; expectedHeader = "a1,a2,a3"; file = "QuotedCharacter.csv" ; content = $quotedCharacterCsv ; delimiter = ',' } | ||
| ){ | ||
| param($expectedHeader, $file, $content, $delimiter) | ||
| Set-Content testdrive:/$file -Value $content |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Usualy we do this in BeforeAll block. Then we could pass only file name to the block.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Having it in BeforeAll makes sense if multiple tests use the same test content, but in this case only this test uses them so I think it's ok to just have it here closer to the test code.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Topping Thanks for your contribution! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.