if statement - Powershell CSV import and update IF function -
i have .csv file wish work in powershell. .csv has 3 columns
accountnumber1, accountnumber2, order
the data can in number of variables
now data non consistent, there accountnumber2. if accountnumber1 exists account number needs used.
other import-csv options have no ideas on how progress this, wondered if length = 0 or around unsure.
easy in excel prefer not write excel function in feel layer of complexity shouldn't need.
import-csv -literalpath 'l:\slist.txt' -headers accountnumber1,accountnumber2,correctac,order
excel be; =if(a2="",b2,a2)
how completed in ps?
use calculated properties replace empty accountnumber1
fields:
$headers = 'accountnumber1','accountnumber2','correctac','order' import-csv -literalpath 'l:\slist.txt' -headers $headers | select-object -property *,@{n='accountnumber1';e={ if (! $_.accountnumber1) {$_.accountnumber2} }} -exclude accountnumber1
Comments
Post a Comment