You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the last cell of an unquotedCsv 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,Note01,John,02,Jack,03,Ryan,Just a note04,Luke,05,Noah,'@$Data.Note.ForEach{ if ($Null-eq$_) { 'Null' } else { 'String' } }
Expected behavior
StringStringStringStringString
Actual behavior
StringStringStringStringNull
As 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.
Error details
No response
Environment data
Name Value
---------
PSVersion 7.2.5
PSEdition Core
GitCommitId 7.2.5
OS Microsoft Windows 10.0.22000
Platform Win32NT
PSCompatibleVersions {1.0,2.0,3.0,4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
If the last cell of an unquoted
Csvfile is empty, the cmdletsConvertFrom-CsvandImport-Csvinconsistently returns a$Nullrather than am empty string.Steps to reproduce
Expected behavior
Actual behavior
As shown above all other cells in the above
Notecolumn 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.Error details
No response
Environment data
See also: how to filter empty values in a column in powershell