I have a CSV file where some of the cells have a blank space in them, and others are just empty. If I run
" " -eq ""
It returns False so Powershell itself understands the difference between a blank space and an empty string. But, I have a CSV file with the following content:
Header0,Header1,Header2,Header3
FillerData, ,,FillerData
When I import this and compare it I get the following:
PS C:\> $MyCSV = Import-Csv -Path "C:\MyCSV.csv"
PS C:\> $MyCSV.Header1 -eq " "
False
PS C:\> $MyCSV.Header1 -eq ""
True
PS C:\> $MyCSV.Header2 -eq " "
False
PS C:\> $MyCSV.Header2 -eq ""
True
So, Import-Csv defaults to treating CSV entries with a blank space as equal to an empty string, when they're not equal. I really need to import the blank spaces for my use case. Is there any way to make Import-Csv correctly import the blank spaces instead of treating them as empty strings?