0

When I run this python file I'm getting an error in the console: File "Documents/test.py", line 4 xlrd-0.9.3\xlrd\ ^ SyntaxError: invalid syntax

How do I load the xlrd package? Here is where I downloaded the package from: http://www.python-excel.org/

Note: The xlrd-0.9.3 folder that I downloaded is on the same level as this .py file:

import urllib
xlrd-0.9.3\xlrd\
import xlrd

url = "http://us.spindices.com/idsexport/file.xls?hostIdentifier=48190c8c-42c4-46af-8d1a-0cd5db894797&selectedModule=PerformanceGraphView&selectedSubModule=Graph&yearFlag=all&indexId=10001901"

urllib.urlretrieve(url, "test1.xls")


rb = xlrd.open_workbook('test1.xls',formatting_info=True)
sheet = rb.sheet_by_index(0)
for rownum in range(sheet.nrows):
row = sheet.row_values(rownum)
for c_el in row:
    print c_el
NewToJS
  • 2,011
  • 4
  • 35
  • 62

1 Answers1

0

Try xlrd package:

import xlrd
rb = xlrd.open_workbook('document.xls',formatting_info=True)
sheet = rb.sheet_by_index(0)
for rownum in range(sheet.nrows):
    row = sheet.row_values(rownum)
    for c_el in row:
        print c_el
rutsky
  • 3,900
  • 2
  • 31
  • 30