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: 3
      Replies: 421
      Points: 1,479
      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: 5
      Replies: 2373
      Points: 6,011
      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: 29
      Points: 272
      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 2 weeks, 6 days ago by AndySvints.
Viewing 3 reply threads
  • You must be logged in to reply to this topic.