merging info from 2 files into 1

Hi,

I have 2 files that I need to combine. I'm not sure if there is an easy way to use grep or something to combine them how i need.

Basically I have 2 csv files. Each file shares an ID for a line of information, but has a bunch of other so I can't easily combine them.

file1: <ID>,<info>,<info>,<info>,<info>, etc
file2: <ID>, <other info>,<other info>, etc

File2 has a few hundred lines, which I need to pull and merge the info from file1 which has a couple thousand lines.

I need a way to search and match the exact "<ID>," and then put that line from file1 onto the line in file2 that matches.

I hope that makes sense how i explained it. Any help would be greatly appreciated.

Thank you

Maybe the "join" command is what you are looking for.

Something like the following would allow you to create arrays as you read thru each of your files. The following STARTS the coding for awk to read and set some variables to arrays. This still needs logic on what to write out to a work (output) file, and also ENDING logic. [Don't want to do everything for you.]
If you think this might be a way to go, you could start with this coding and research on how to do the remaining awk commands necessary.

awk -v wrk1=$workfile1ns -v wrk2x=$workfile2x '
      BEGIN {
         FSf1=","
         FSf2=","
      }
      FNR == 1 {
          if (FILENAME==wrk2x) FS=FSf2
          if (FILENAME==wrk1) FS=FSf1
          $0=$0
      }
      FILENAME==wrk1 { 
         medx[$1]=$2
         }

      FILENAME==wrk2x{ 
         ua1_pl[$1]=$2
         }