【问题标题】:Store specific value from csv into variable using powershell使用powershell将csv中的特定值存储到变量中
【发布时间】:2012-05-17 04:02:27
【问题描述】:

我有一个像这样的 csv 文件

"NumberofNullAsOfDates"
"0"

我想检查那里是否有 0 或任何其他值。这是我目前拥有的 powershell 代码,但效果似乎不太好。

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

我怎样才能使这项工作使 $testNum 只包含“0”(不带引号)

【问题讨论】:

    标签: arrays powershell csv


    【解决方案1】:

    您可以将值转换为 int:

    $intValue = [int]$testNum[1]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-23
      • 2022-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-27
      • 2015-10-07
      • 1970-01-01
      相关资源
      最近更新 更多