Download multiple xls files using Python

Tim Chase python.list at tim.thechases.com
Thu Feb 12 20:14:46 EST 2015


On 2015-02-13 11:19, Chris Angelico wrote:
> On Fri, Feb 13, 2015 at 11:07 AM,  <polleysarah7 at gmail.com> wrote:
> > Here is an example of my problem. I have for the moment a CSV
> > file named "Stars" saved on my windows desktop containing around
> > 50.000 different links that directly starts downloading a xls
> > file when pressed. Each row contains one of these links. I would
> > want with your help create some kind of script for this that will
> > make some kind of loop thru each row and visit this different
> > links so it can download these 50.000 different files.
> 
> In short: Loop over the lines in the file, as returned by the CSV
> reader, and for each line, fire off a request to fetch its XLS file,

Alternatively, unless you're wed to Python, downloading tools like
"wget" are your friend and make quick work of this.  Just extract the
column of URLs into a file (which can be done in Excel or with any
number of utilities such as "cut") and then use "wget" to pull them
all down:

  cut -d, -f3 < data.csv > urls.txt
  wget -i urls.txt

(the above assumes that column #3 contains the URLs)

-tkc





More information about the Python-list mailing list