Hi - experienced programmer but this is my first Python program.
This URL will retrieve an excel spreadsheet containing (that day's)
msci stock index returns.
Want to write python to download and save the file.
So far I've arrived at this:
This URL will retrieve an excel spreadsheet containing (that day's)
msci stock index returns.
Want to write python to download and save the file.
So far I've arrived at this:
# import pdb
import urllib2
from win32com.client import Dispatch
xlApp = Dispatch("Excel .Application")
# test 1
# xlApp.Workbooks .Add()
# xlApp.ActiveShe et.Cells(1,1).V alue = 'A'
# xlApp.ActiveWor kbook.ActiveShe et.Cells(2,1).V alue = 'B'
# xlBook = xlApp.ActiveWor kbook
# xlBook.SaveAs(F ilename='C:\\te st.xls')
# pdb.set_trace()
response = urllib2.urlopen ('http://www.mscibarra.c om/webapp/indexperf/
excel?
priceLevel=0&sc ope=0¤cy= 15&style=C&size =36&market=1897 &asOf=Jul
+25%2C+2008&exp ort=Excel_IEIPe rfRegional')
# test 2 - returns check = False
check_for_data = urllib2.Request ('http://www.mscibarra.c om/webapp/
indexperf/excel?
priceLevel=0&sc ope=0¤cy= 15&style=C&size =36&market=1897 &asOf=Jul
+25%2C+2008&exp ort=Excel_IEIPe rfRegional').ha s_data()
xlApp = response.fp
print(response. fp.name)
print(xlApp.nam e)
xlApp.write
xlApp.Close
import urllib2
from win32com.client import Dispatch
xlApp = Dispatch("Excel .Application")
# test 1
# xlApp.Workbooks .Add()
# xlApp.ActiveShe et.Cells(1,1).V alue = 'A'
# xlApp.ActiveWor kbook.ActiveShe et.Cells(2,1).V alue = 'B'
# xlBook = xlApp.ActiveWor kbook
# xlBook.SaveAs(F ilename='C:\\te st.xls')
# pdb.set_trace()
response = urllib2.urlopen ('http://www.mscibarra.c om/webapp/indexperf/
excel?
priceLevel=0&sc ope=0¤cy= 15&style=C&size =36&market=1897 &asOf=Jul
+25%2C+2008&exp ort=Excel_IEIPe rfRegional')
# test 2 - returns check = False
check_for_data = urllib2.Request ('http://www.mscibarra.c om/webapp/
indexperf/excel?
priceLevel=0&sc ope=0¤cy= 15&style=C&size =36&market=1897 &asOf=Jul
+25%2C+2008&exp ort=Excel_IEIPe rfRegional').ha s_data()
xlApp = response.fp
print(response. fp.name)
print(xlApp.nam e)
xlApp.write
xlApp.Close
Comment