title: csv writing last row only in python
body: <p>below is console output parsed from url saving only last row into csv</p>
  <pre><code>['id=35942&amp;requestId=1615320149894&amp;ln=1000043845']
  ['id=35943&amp;requestId=1615320149894&amp;ln=1000043833']
  ['id=35944&amp;requestId=1615320149894&amp;ln=1000043832']
  ['id=35945&amp;requestId=1615320149894&amp;ln=1000043831']
  ['id=35946&amp;requestId=1615320149894&amp;ln=1000043845']
  
  </code></pre>
  <p><a href="https://i.stack.imgur.com/zBqck.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zBqck.png" alt="pythonprints" /></a>
  import re
  import csv</p>
  <pre><code>links = driver.find_elements(By.LINK_TEXT, 'Submit') // link attributes
  len(links)
  for link in links:
      a = link.get_attribute('href')  //getting all the links 
      # print(a)
      parsed = urlparse(a)  //parsing the urls
      path = parsed[-2]  
      pathlist = path.split(&quot;/&quot;)
     # itm = len(pathlist)
      print(pathlist)
      with open('myfile.csv', 'w') as f:
          writer = csv.writer(f)
          for itm in pathlist:
              writer.writerow(re.findall(r'\d+', str(itm)))
  
  </code></pre>
  <p>and csv file is writing only last row
  <code>35946,1615320149894,1000043845</code></p>