Powershell ForEach, ignore blanks in csv

72 Views Asked by At

Powershell is a completely foreign language to me, but I am trying to do this project where I am going through a list of Tickers in a csv file and if the tickers exist, I want to extract those and add them to my list. However, if the ticker is blank, I want the code to get the sedol. Can you help fix this line?

$pos = $text | Select-Object -Skip $i -First ($end-$i) | ConvertFrom-Csv;
$pos | ForEach-Object {if ($_.Ticker.Substring(1) -ne $null) {$_.Ticker = $_.Ticker.Substring(1)} else {
            {$_.Ticker = $_.SEDOL.Substring(1)}
        }}

Here is what the $pos object looks like:

enter image description here

0

There are 0 best solutions below