2

Lets say I have a csv with the following columns:

  A        B
   2     1000
  10     1000
 199     1000
9101     1000

I am looking to have column A right fill column B to have a result like the following:

 B
1002
1010
1199
9101

How can I achieve this output?

Thanks!

1 Answer 1

3

You could use Select-Object with a calculated property to "merge" the two into one:

# Import existing data
$data = Import-Csv path\to\data.csv 

# Create a new property B with the value of the existing A + B
$data = $data |Select @{Name = 'B'; Expression = { [int]$_.A + $_.B }}

# Export to a new CSV file
$data | Export-Csv path\to\new.csv
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.