我有一个我读过的CSV。问题是这个CSV作为未填充数据的列。我需要浏览一个列,当ID号与我要添加的内容的ID匹配时,添加数据。目前我有,
$counter = 0
foreach($invoice in $allInvoices){
$knownName += $info | where-Object{$_.'DOCNUMBR'.trim().contains($cleanInvNum)}
$DocNumbr = $info | where-Object{$_.'DOCNUMBR'.trim() -eq $cleanInvNum}
$output = $ResultsTable.Rows.Add(" ", " ", " ", " ", $DocNumbr[$counter].'ORG', $DocNumbr[$counter].'CURNT', $knownName[$counter].'DOCNUMBR', " ")
$counter++
}
此代码的问题在于它只是在CSV下添加行而不会将数据添加到行中。我怎样才能找到ID并将上述内容添加到该行?
答案 0 :(得分:1)
我能够通过重新编写foreach循环并直接设置值来解决我的问题,
$output.'CheckNumber' = $DocNumbr.'ORTRXAMT'
$output.'CheckDate' = $DocNumbr.'CURTRXAM'
$output.'Invoice Number' = $knownName.'DOCNUMBR'