Updating values under a header name in a csv file

Welcome Forums General PowerShell Q&A Updating values under a header name in a csv file

Viewing 3 reply threads
  • Author
    Posts
    • #236494
      Participant
      Topics: 1
      Replies: 0
      Points: 12
      Rank: Member

      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”

      …….

       

    • #236554
      Participant
      Topics: 6
      Replies: 552
      Points: 2,090
      Helping Hand
      Rank: Community Hero

      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.

    • #236677
      Participant
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP

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

      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. 😉

    • #236734
      Participant
      Topics: 0
      Replies: 37
      Points: 371
      Helping Hand
      Rank: Contributor

      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

      • This reply was modified 3 months ago by AndySvints.
Viewing 3 reply threads
  • The topic ‘Updating values under a header name in a csv file’ is closed to new replies.