I'm somewhat new to scripting in general. I have a CSV file which I am importing and modifying the data so it presents in a better format.
My question is I want to do (I guess) a foreach loop on all rows of a given column, and if data does not match a certain criteria:
- Copy the entire row onto a new row (retaining all other data in the row).
- Replace the value of "Column B" with the value of "Column C"
I'm basically doing an import-csv $file
. I'll export it later on.
Here is an example: I basically want to move Task2 into the Task1 column IF there is any data present except "--", and then I can ignore the Task 2 column.
Import-csv
gives me this:
ID, TASK1, TASK2
123, A, --
456, B, --
789, C, D,
But I want it to look like this:
ID, TASK1, TASK2
123, A , --
456, B, --
789, C, D,
789, D, D,
Other method: