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.

enter image description here

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

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -