Skip to content

Fix pandas.io.parsers.parseExcel to be more robust / have correct handling of Excel dates #9

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

Closed
wesm opened this issue Sep 30, 2010 · 2 comments

Comments

@wesm
Copy link
Member

wesm commented Sep 30, 2010

No description provided.

@wesm
Copy link
Member Author

wesm commented Sep 30, 2010

A user suggested this version to start with:

from datetime import datetime,time

def parseExcel(filepath, sheetname, header=False, indexCol=0):
   # ImportError is quite clear already ;-)
   import xlrd
   book = xlrd.open_workbook(filepath)
   sheet = book.sheet_by_name(sheetname)
   data = []
   for rowx in range(sheet.nrows):
       row = []
       for value,type in zip(
           sheet.row_values(i),
           sheet.row_types(i)
           ):
           if type==xlrd.XL_CELL_DATE:
               dt = xldate_as_tuple(value, book.datemode)
               if dt[0] < datetime.MINYEAR:
                   value = time(*dt[3:])
               else:
                   value = datetime(*dt)
           row.append(value)
       data.append(row)
   return simpleParser(data, header = header, indexCol = indexCol)

@wesm
Copy link
Member Author

wesm commented May 18, 2011

addressed in

wesm@6e38eca

thanks to Chris Withers for the help with this

@wesm wesm closed this as completed May 18, 2011
jbrockmendel pushed a commit to jbrockmendel/pandas that referenced this issue Dec 29, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Another 24024 rebase
YasithDSL pushed a commit to YasithDSL/pandas that referenced this issue Nov 9, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
New err mypy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant