0

So I'm just starting out with this whole Powershell thing and so far so good - until now. I just can't figure out how to do this! I'm looking at manipulating CSV files which are output from one system (which I can't change at output), renaming some column headers and merging a couple of the results into one column so that it matches the input requirements to upload into another system (again, I can't change those parameters). So, as an example.

The first file is created: File1.csv "A","B","C""1","2","3"

I want a powershell script that will output: File2.csv "X","Y""1","23" So I can import it into another system.

I hope that all makes sense, and thanks in advance for any assistance.

1 Answer 1

1

I'm going to assume that your actual/desired formats of your files look like this:

"A","B","C"
"1","2","3"
"X","Y"
"1","23"

rather than having everything in one line. If that's correct you can import File1.csv with Import-Csv, rename and merge columns with calculated properties:

... | Select-Object @{n='X';e={$_.A}}, @{n='Y';e={$_.B + $_.C}} | ...

and write the result to File2.csv with Export-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.