title: Looking up values of one csv file in another csv file and print the row
body: <p>I have two csv files, one is a single column with a header and the other is multiple columns with headers. I want to lookup the values in the one column file and search the column with the same header in the other file. Once a match is found, I want that whole row to be printed. I know this is a vlookup function, but the csv file with multiple columns is extremely large and always crashes excel when I try to use formulas to accomplish this. So I've been trying to use python as a solution.</p>
  
  <p>I'm taking this column:</p>
  
  <pre><code>age
  23
  43
  18
  </code></pre>
  
  <p>Searching this table:</p>
  
  <pre><code>Name,   age,number,AA,BB,CC,DD,EE
  John,   23,   1,   34,35,36,37,38
  Mary,   32,   2,   33,34,35,36,37
  Jacob , 43,   3,   32,33,34,35,36
  Matthew,22,   4,   31,32,33,34,35
  Jean,   18,   5,   30,31,32,33,34
  </code></pre>
  
  <p>trying to print this:</p>
  
  <pre><code>Name,   age,number,AA,BB,CC,DD,EE
  John,   23,   1,   34,35,36,37,38
  Jacob , 43,   3,   32,33,34,35,36
  Jean,   18,   5,   30,31,32,33,34
  </code></pre>
  
  <p>I've been trying to use this code, but I got all mixed up and it just prints the first row as a column:</p>
  
  <pre><code>with open('/home/s/Untitled 1.csv') as f:
  r=pandas.read_csv(f)
  with open('/home/s/Test1.csv','r') as w:
      x=pd.read_csv(w)
      col=w['age']
      for line in w:
          for col in w:
              for row in r:
                  if row in col:
                      print(line)
  </code></pre>
  
  <p>I basically want the script to use the first entry in the query column to search the column with the same heading in the data table and print that row, looping for the rest of the entries in the rows below. </p>
  
  <p>Any advice would be appreciated!</p>