title: Python download files by links stored in csv
body: <p>As a newbie in Python (2.7) I`m looking for next suggestion:</p>
  
  <p>I have a csv file with stored http links in one column comma delimited.</p>
  
  <pre><code>http://example.com/file.pdf,
  http://example.com/file.xls,
  http://example.com/file.xlsx,
  http://example.com/file.doc,
  </code></pre>
  
  <p>The main aim is to loop through all these links and download files by them in original extention and name.</p>
  
  <p>So my search results and help here gave me next script:</p>
  
  <pre><code>import urllib2
  import pandas as pd 
  
  links = pd.read_csv('links.csv', sep=',', header =(0))
  
  url = links                   # I know this part wrong by don`n know how to do right
  
  user_agent = 'Mozilla 5.0 (Windows 7; Win64; x64)'
  
  file_name = "tessst"          # here the files name by how to get their original names
  
  u = urllib2.Request(url, headers = {'User-Agent' : user_agent})
  req = urllib2.urlopen(u)
  f = open(file_name, 'wb')
  f.write(req.read())
  
  f.close()
  </code></pre>
  
  <p>please any help</p>
  
  <p>P S not sure about pandas - maybe csv better? </p>