pydata/pandas — Issue #837: ExcelFile throws an exception if parsing a file with only two lines
Author: cswegger
Created: 2012-02-28 09:20:30+00:00
State: open

Example (paste this in an Excel file):

Test Test1
aaaa bbbbb

````python
excel_data = pandas.ExcelFile("test.xls")
parsed = pandas.parse("Sheet1")

/usr/lib64/python2.7/site-packages/pandas-0.8.0.dev_3beba2c-py2.7-linux-x86_64.egg/pandas/io/parsers.pyc in parse(self, sheetname, header, skiprows, index_col, parse_dates, date_parser, na_values, chunksize)
629 parse_dates=parse_dates,
630 date_parser=date_parser,
--> 631 na_values=na_values, chunksize=chunksize)
632
633 def _parse_xlsx(self, sheetname, header=0, skiprows=None, index_col=None,

/usr/lib64/python2.7/site-packages/pandas-0.8.0.dev_3beba2c-py2.7-linux-x86_64.egg/pandas/io/parsers.pyc in _parse_xls(self, sheetname, header, skiprows, index_col, parse_dates, date_parser, na_values, chunksize)
684 date_parser=date_parser,
685 skiprows=skiprows,
--> 686 chunksize=chunksize)
687
688 return parser.get_chunk()

/usr/lib64/python2.7/site-packages/pandas-0.8.0.dev_3beba2c-py2.7-linux-x86_64.egg/pandas/io/parsers.pyc in __init__(self, f, delimiter, names, header, index_col, na_values, parse_dates, date_parser, chunksize, skiprows, skip_footer, converters, verbose, encoding)
262 self.data = f
263 self.columns = self._infer_columns()
--> 264 self.index_name = self._get_index_name()
265 self._first_chunk = True
266

/usr/lib64/python2.7/site-packages/pandas-0.8.0.dev_3beba2c-py2.7-linux-x86_64.egg/pandas/io/parsers.pyc in _get_index_name(self)
381
382 try:
--> 383 next_line = self._next_line()
384 except StopIteration:
385 next_line = None

/usr/lib64/python2.7/site-packages/pandas-0.8.0.dev_3beba2c-py2.7-linux-x86_64.egg/pandas/io/parsers.pyc in _next_line(self)
351 self.pos += 1
352
--> 353 line = self.data[self.pos]
354 else:
355 while self.pos in self.skiprows:

IndexError: list index out of range
````

Works correctly if the number of lines is at least 3.