Title: The last cell of an empty column read by `ConvertFrom-Csv` is inconsistently `$Null` · Issue #17702 · PowerShell/PowerShell · GitHub
Open Graph Title: The last cell of an empty column read by `ConvertFrom-Csv` is inconsistently `$Null` · Issue #17702 · PowerShell/PowerShell
X Title: The last cell of an empty column read by `ConvertFrom-Csv` is inconsistently `$Null` · Issue #17702 · PowerShell/PowerShell
Description: If the last cell of an unquoted Csv file is empty, the cmdlets ConvertFrom-Csv and Import-Csv inconsistently returns a $Null rather than am empty string. Steps to reproduce $Data = ConvertFrom-Csv @' Id,Name,Note 01,John, 02,Jack, 03,Rya...
Open Graph Description: If the last cell of an unquoted Csv file is empty, the cmdlets ConvertFrom-Csv and Import-Csv inconsistently returns a $Null rather than am empty string. Steps to reproduce $Data = ConvertFrom-Csv ...
X Description: If the last cell of an unquoted Csv file is empty, the cmdlets ConvertFrom-Csv and Import-Csv inconsistently returns a $Null rather than am empty string. Steps to reproduce $Data = ConvertFrom-Csv ...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/17702
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"The last cell of an empty column read by `ConvertFrom-Csv` is inconsistently `$Null`","articleBody":"If the last cell of *an unquoted* `Csv` file is empty, the cmdlets `ConvertFrom-Csv` and `Import-Csv` inconsistently returns a `$Null` rather than am empty string.\r\n\r\n### Steps to reproduce\r\n\r\n```PowerShell\r\n$Data = ConvertFrom-Csv @'\r\nId,Name,Note\r\n01,John,\r\n02,Jack,\r\n03,Ryan,Just a note\r\n04,Luke,\r\n05,Noah,\r\n'@\r\n\r\n$Data.Note.ForEach{ if ($Null -eq $_) { 'Null' } else { 'String' } }\r\n```\r\n\r\n### Expected behavior\r\n\r\n```console\r\nString\r\nString\r\nString\r\nString\r\nString\r\n```\r\n\r\n\r\n### Actual behavior\r\n\r\n```console\r\nString\r\nString\r\nString\r\nString\r\nNull\r\n```\r\n\r\nAs shown above all other cells in the above `Note` column are interpreted as string, except for the last cell with appears to be `$Null`. This would have been correct if the last comma was omitted but that is not the case.\r\n\r\n\r\n### Error details\r\n\r\n_No response_\r\n\r\n### Environment data\r\n\r\n```powershell\r\nName Value\r\n---- -----\r\nPSVersion 7.2.5\r\nPSEdition Core\r\nGitCommitId 7.2.5\r\nOS Microsoft Windows 10.0.22000\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n```\r\n\r\nSee also: [how to filter empty values in a column in powershell](https://stackoverflow.com/questions/75659764/how-to-filter-empty-values-in-a-column-in-powershell)","author":{"url":"https://github.com/iRon7","@type":"Person","name":"iRon7"},"datePublished":"2022-07-18T10:22:14.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":21},"url":"https://github.com/17702/PowerShell/issues/17702"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c42709bd-aef5-bd7c-b688-0a8a6212a6bb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A820:24A3F5:FF8CE8:14F699D:6A5C3EF1 |
| html-safe-nonce | ca1038a8182bd06fea8b9ac5d4335442d96ad4b3894ae807e63fd09c0fc09fa0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBODIwOjI0QTNGNTpGRjhDRTg6MTRGNjk5RDo2QTVDM0VGMSIsInZpc2l0b3JfaWQiOiI5MTM0NjU4MTMxOTMwNjYwNTkzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | cfad0dd01538dae3d6e5960aba58667e4337864d4320069fbca1396ca9df4c28 |
| hovercard-subject-tag | issue:1307730896 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/17702/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8e9a99e4224f754d9f9242cf107ca0b9275dcf1e3b763e00bed68aea62d2c90e/PowerShell/PowerShell/issues/17702 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8e9a99e4224f754d9f9242cf107ca0b9275dcf1e3b763e00bed68aea62d2c90e/PowerShell/PowerShell/issues/17702 |
| og:image:alt | If the last cell of an unquoted Csv file is empty, the cmdlets ConvertFrom-Csv and Import-Csv inconsistently returns a $Null rather than am empty string. Steps to reproduce $Data = ConvertFrom-Csv ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | iRon7 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width