Updating values under a header name in a csv file

Hi All,

I have CSV file(user.csv) that is generated with a header name “name” and another .csv(mycsv.csv) file which contains column with data.

I need to import data from mycsv.csv file to user.csv file and write it under header name “name”.

example:-

user.csv

“name”

mycsv.csv

“H1”

“abc”

“dfg”

 

OK so what have you tried and what errors are you seeing? Also, please read the very first post https://powershell.org/forums/topic/read-me-before-posting-youll-be-glad-you-did/ and simply update your post to correct it.

With the information you gave until now I’d recommend to add a new line with the content “name” as the first line in your “mycsv.csv” and you’re done. :wink:

Agree with Olaf and Doug description is very vague.

Is there any data in first file?

You want to append data from second file to the first?

Or maybe you just want to import data from second with new headers?

For the latter you can use Import-Csv -Header (Specifies an alternate column header row for the imported file.)

Please refer to documentation for more details:

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/import-csv?view=powershell-7