Skip to content

Commit 95cfc7c

Browse files
committed
BUG: close #837, excelfile throws an exception for two-line file
1 parent 71244f2 commit 95cfc7c

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

RELEASE.rst

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pandas 0.7.1
5050
- Fix exception thrown on np.diff (#816)
5151
- Fix to_records where columns are non-strings (#822)
5252
- Fix Index.intersection where indices have incomparable types (#811)
53+
- Fix ExcelFile throwing an exception for two-line file (#837)
5354

5455
pandas 0.7.0
5556
============

pandas/io/parsers.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,10 @@ def _next_line(self):
350350
while self.pos in self.skiprows:
351351
self.pos += 1
352352

353-
line = self.data[self.pos]
353+
try:
354+
line = self.data[self.pos]
355+
except IndexError:
356+
raise StopIteration
354357
else:
355358
while self.pos in self.skiprows:
356359
self.data.next()

pandas/io/tests/test2.xls

5.5 KB
Binary file not shown.

pandas/io/tests/test_parsers.py

+6
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@ def test_read_csv_no_index_name(self):
219219
self.assert_(df.ix[:, ['A', 'B', 'C', 'D']].values.dtype == np.float64)
220220
assert_frame_equal(df, df2)
221221

222+
def test_excel_stop_iterator(self):
223+
excel_data = ExcelFile(os.path.join(self.dirpath, 'test2.xls'))
224+
parsed = excel_data.parse('Sheet1')
225+
expected = DataFrame([['aaaa','bbbbb']], columns=['Test', 'Test1'])
226+
assert_frame_equal(parsed, expected)
227+
222228
def test_excel_table(self):
223229
try:
224230
import xlrd

0 commit comments

Comments
 (0)