Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExcelFile throws an exception if parsing a file with only two lines #837

Closed
lbeltrame opened this issue Feb 28, 2012 · 0 comments
Closed
Labels
Milestone

Comments

@lbeltrame
Copy link
Contributor

Example (paste this in an Excel file):

Test Test1
aaaa bbbbb

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

/usr/lib64/python2.7/site-packages/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/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/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/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/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. Pandas is from yesterday's git (path names have been slightly trimmed to improve readability).

yarikoptic added a commit to neurodebian/pandas that referenced this issue Mar 2, 2012
* commit 'v0.7.1-1-ga2e86c2': (90 commits)
  BUG: Fix Series, DataFrame plot() for non numerical/datetime (Multi)Index (closes pandas-dev#741).
  RLS: Version 0.7.1
  DOC: release notes, what's new, change dev version to 0.7.1
  BUG: close pandas-dev#839, another case where nan may be assigned to int series
  ENH: raise NotImplementedError if user tries to iterate over .ix, GH pandas-dev#840
  BUG: fixed null-check per pandas-dev#839
  BUG: close pandas-dev#839, exception on assigning NA to bool or int64 series
  TST: more test coverage for release target
  TST: added core coverage
  TST: fix lingering line of code from pandas-dev#838
  DOC: added yet a bit more to release notes
  TST: unit test for pandas-dev#838
  DOC: added more release notes
  BUG: raise more helpful error msg for pandas-dev#835
  TST: added skip excel test for no xlrd installed
  BUG: close pandas-dev#835, add option to suppress index inference
  BUG: close pandas-dev#837, excelfile throws an exception for two-line file
  ENH: fill_value arg in DataFrame.reindex/reindex_axis, add fillna to sparse objects, GH pandas-dev#784
  ENH: add fill_value argument to Series.reindex, DataFrame next, pandas-dev#784
  ENH: concat Series with axis=1 for completeness, GH pandas-dev#787
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants