title: Loop retrieve data from csv, append to file
body: <p>I have created a Python 2.7 script that does the following:</p>
  
  <blockquote>
    <ol>
    <li>Gets a list of filenames from a folder, and writes them to a csv file, one for each row.</li>
    </ol>
  </blockquote>
  
  <p>And </p>
  
  <blockquote>
    <ol start="2">
    <li>Enters data into a search box on the web.</li>
    <li>Writes the result from the search box into another csv file.</li>
    </ol>
  </blockquote>
  
  <p>So what I would like now, is for the csv data in (1 ) to act as the input for (2 ).</p>
  
  <p>i.e. for each filename in the csv file, it conducts a search for that cell.</p>
  
  <p>Additionally, instead of just writing the results into a second csv file in (3 ), I would like to append the result into the first csv file – OR generate a new one with both columns.</p>
  
  <p>I can provide the code, but since it's 50 lines already, I've just tried to keep this question descriptive.</p>
  
  <p><strong>Update: Proposed retrieval and append:</strong></p>
  
  <pre><code>with open("file.csv","a+") as f:
      r = csv.reader(f)
      wr = csv.writer(f, delimiter="\n")
      result = []
      for line in r:
          searchbox = driver.find_element_by_name("searchbox")
          searchbox.send_keys(line)
  
          sleep(8)
  
          search_reply = driver.find_element_by_class_name("search_reply")
  
          result = re.findall("((?&lt;=\()[0-9]*)", search_reply.text)
      wr.writerow(result)
  </code></pre>