I'm trying to grab a data file using urllib.urlopen with this code: def powerData(self,REQUEST): import csv import urllib inFile = urllib.urlopen('http://www.davisenergy.com/zeh_data/A042304.DAT') return inFile but I get the error: global name 'inFile' is not defined I've also tried some variations on this: inFile = "".join(urllib.urlopen('http://www.davisenergy.com/zeh_data/ A042304.DAT').readlines()) Ideas on what's not working? thanks -- David
On Monday 16 August 2004 06:33, David Siedband wrote:
I'm trying to grab a data file using urllib.urlopen
with this code:
def powerData(self,REQUEST): import csv import urllib inFile = urllib.urlopen('http://www.davisenergy.com/zeh_data/A042304.DAT')
return inFile
but I get the error: global name 'inFile' is not defined
the whole trace back would be nice also, does this work from the command line? <plug type="shameless"> check out Kebasdata sf.net/projects/kebasdata it grabs data from accessable url, and then you can actually do stuff withit (thru Script (Python), or External Method) p/s - my member page at zope also has a howto. </plug>
I've also tried some variations on this:
inFile = "".join(urllib.urlopen('http://www.davisenergy.com/zeh_data/ A042304.DAT').readlines())
Ideas on what's not working? thanks
-- David
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Heyho! David Siedband wrote:
I'm trying to grab a data file using urllib.urlopen
with this code:
def powerData(self,REQUEST): import csv import urllib inFile = urllib.urlopen('http://www.davisenergy.com/zeh_data/A042304.DAT')
return inFile ^^^^Your indention is wrong, the return statement should be inside the powerData-function.
Ideas on what's not working? thanks
-- David
HTH, Wolfram
David Siedband wrote:
I'm trying to grab a data file using urllib.urlopen
with this code:
def powerData(self,REQUEST): import csv import urllib inFile = urllib.urlopen('http://www.davisenergy.com/zeh_data/A042304.DAT')
return inFile
Is that return statement indented correctly? it should be at the same level as the import and inFile = cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
here, you've defined inFile within the scope of powerData, but then you are using inFile outside the scope of powerData. indention matters. http://docs.python.org/tut/node6.html (4.6 Defining Functions) thanks, travis On Aug 15, 2004, at 5:33 PM, David Siedband wrote:
def powerData(self,REQUEST): import csv import urllib inFile = urllib.urlopen('http://www.davisenergy.com/zeh_data/A042304.DAT')
return inFile
participants (5)
-
Bakhtiar A Hamid -
Chris Withers -
David Siedband -
Travis Miller -
Wolfram Kraus