mhopkins321
mhopkins321

Reputation: 3083

Store specific value from csv into variable using powershell

I have a csv file that looks like this

"NumberofNullAsOfDates"
"0"

I would like to check if there is a 0 or any other value there. This is currently the powershell code I have but it doesn't seem to work out so well.

$testNum = @()
$testNum += Import-Csv craneAudit.csv
$testNum[1]

How could I make this work so that $testNum only contains "0" (without quotes)

Upvotes: 1

Views: 319

Answers (1)

David Brabant
David Brabant

Reputation: 43559

You can cast the value to int:

$intValue = [int]$testNum[1]

Upvotes: 2

Related Questions