python - Trying to download data from URL with CSV File -
i'm new python , have question why following code doesn't produce output in csv
file. code follows:
import csv import urllib2 url = 'http://www.rba.gov.au/statistics/tables/csv/f17-yields.csv' response = urllib2.urlopen(url) cr = csv.reader(response) row in cr: open("auscentralbank.csv", "wb") f: writer = csv.writer(f) writer.writerows(row)
cheers.
edit:
brien , albert solved initial issue had. however, have 1 further question. when download csv file have listed above in "http://www.rba.gov.au/statistics/tables/#interest-rates" under zero-coupon "interest rates - analytical series - 2009 current - f17" , f-17 yields csv see has 5 workbooks , want gather data in 5th workbook. there way this? cheers.
@albert had great answer. i've gone ahead , converted equivalent python 2.x code. doing bit work in original program; since file csv didn't need special work turn csv.
import urllib2 url = 'http://www.rba.gov.au/statistics/tables/csv/f17-yields.csv' response = urllib2.urlopen(url) html = response.read() open('auscentralbank.csv', 'wb') f: f.write(html)
Comments
Post a Comment