mercredi 7 septembre 2016

Powershell CSV import and update IF function

I have a .csv file that I wish to work with in Powershell. The .csv has three columns

AccountNumber1, AccountNumber2, Order

The data can be in a number of variables

Now the data is non consistent, There will always be an AccountNumber2. However If AccountNumber1 exists then this is the account number that needs to be used.

enter image description here

Other than the import-csv options I have no ideas on how to progress this, I wondered about if length = 0 or something around this but completely unsure.

Easy to do in excel but I would prefer not to write an excel function in as feel that its an extra layer of complexity this shouldn't really need.

Import-Csv -literalpath 'L:\SList.txt' -Headers AccountNumber1,AccountNumber2,CorrectAC,Order

Excel would simply be; =IF(A2="",B2,A2) obviously but how this is completed in PS?

Aucun commentaire:

Enregistrer un commentaire