Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #61781

Re: Downloading multiple files based on info extracted from CSV

From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Downloading multiple files based on info extracted from CSV
Date 2013-12-12 20:52 -0500
Organization IISS Elusive Unicorn
References <88346903-2af8-48cd-9829-37cedb717ae5@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.4043.1386899560.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, 12 Dec 2013 13:43:50 -0800 (PST), Matt Graves <tunacubes@gmail.com>
declaimed the following:

>def downloadFile(urls, clientname):
>    urllib.urlretrieve(f, "%g.csv") % clientname
>
	The most blatent error is this line...

	You are calling urllib.urlretrieve passing it arguments of f and the
string "%g.csv".

	THEN you are doing a string interpolation on the RESULT.

	The line should probably be

	urllib.urlretrieve(f, "%s.csv" % clientname)

to apply the string interpolation first, and pass that as the second
argument (also not the %s for /string/ [which, in Python, tends to accept
any argument and produce a general string from it -- using any other format
specification tends to be for cases where you need to match a particular
format... %4.4x if you want zero-filled hex, for example])
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Downloading multiple files based on info extracted from CSV Matt Graves <tunacubes@gmail.com> - 2013-12-12 13:43 -0800
  Re: Downloading multiple files based on info extracted from CSV Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-12 22:19 +0000
  Re: Downloading multiple files based on info extracted from CSV Chris Angelico <rosuav@gmail.com> - 2013-12-13 09:20 +1100
    Re: Downloading multiple files based on info extracted from CSV Matt Graves <tunacubes@gmail.com> - 2013-12-16 06:17 -0800
  Re: Downloading multiple files based on info extracted from CSV John Gordon <gordon@panix.com> - 2013-12-12 22:21 +0000
  Re: Downloading multiple files based on info extracted from CSV Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-12-12 20:52 -0500

csiph-web