code_junkie

How do I read an Excel file into Python using xlrd? Can it read newer Office formats?

Nov 11th, 2011
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. >>> open('ComponentReport-DJI.xls', 'rb').read(200)
  2. 'COMPANY NAMEtPRIMARY EXCHANGEtTICKERtSTYLEtICB SUBSECTORtMARKET CAP RANGE
  3. tWEIGHT PCTtUSD CLOSEtrn3M Co.tNew York SEtMMMtN/AtDiversified Industria
  4. lstBroadt5.15676229508t50.33trnAlcoa Inc.tNew York SEtA'
  5.  
  6. import pyExcelerator
  7. book = pyExcelerator.parse_xls(filename)
  8.  
  9. data = book[0][1]
  10. print 'Cell A1 of worksheet %s is: %s' % (book[0][0], repr(data[(0, 0)]))
  11.  
  12. import pyExcelerator
  13. book = pyExcelerator.parse_xls('DJIAMovers.xls')
Add Comment
Please, Sign In to add comment