我有一個.csv與幾百條記錄,我需要解剖到幾個不同的文件。有一部分代碼需要一個對象數組並基於數組過濾文件。它對於發現與數組中的內容相同的部分很有用,但是當我嘗試根據數組中未包含的內容進行過濾時,它會忽略任何我能找到的「不等於」運算符的版本。我認爲這與數據類型有關,但不能確定當平等運營商工作時爲什麼它會有所作爲。Powershell陣列導出不等於運營商不工作
CSV文件"Number","Ticket","Title","Customer User","CustomerID","Accounted time","Billing"
"1","2014041710000096","Calendar issues","george.jetson","Widget, Inc","0.25","Labor",""
"2","2014041710000087","Redirected Folder permission","jane.smith","Mars Bars, Inc.","1","Labor",""
"3","2014041610000203","Completed with No Files Changed ""QB Data""","will.smith","Dr. Smith","0","Labor",""
PowerShell代碼
$msaClients = @("Widget, Inc","Johns Company")
$billingList = import-csv "c:\billing\billed.csv"
$idZero = "0"
$msaArray = foreach ($msa in $msaClients) {$billingList | where-object {$_.CustomerID -eq $msa -and $_."Accounted time" -ne $idZero}}
$laborArray = foreach ($msa in $msaClients) {$billingList | where-object {$_.CustomerID -ne $msa -and $_."Accounted time" -ne $idZero}}
$msaArray | export-csv c:\billing\msa.csv -notypeinformation
$laborArray | export-csv c:\billing\labor.csv -notypeinformation
我已經嘗試了所有不同的邏輯運算符的不相等,它只是似乎忽略的那部分。如果事情看起來不正確,我還有更多的代碼。
我錯過了什麼,並預先感謝您的幫助!
你絕對搖滾,非常感謝你! – user3550556
很高興我能幫忙:) – Nitesh