Suppressing XLRD warnings


I would like to suppress some warnings from the xlrd module that appears when calling the pd.read_excel function

These are my typical warnings:
WARNING *** file size (608105) not 512 + multiple of sector size (512)
WARNING *** OLE2 inconsistency: SSCS size is 0 but SSAT size is non-zero

One of the solutions to this problem that I see on the web is to filter those via a log filter, see:

But that would require having access to specify the logger in the read_excel function arguments.

Or is there another solution ?


Author: Fantashit

2 thoughts on “Suppressing XLRD warnings

  1. I think the proper solution is for xlrd to use the logging module. There’s an issue here, if you want to resurrect it, or maybe submit a PR to xlrd.

    In the meantime, does opening the workbook your self manually, and passing that to read_excel work for you?

    Something like

    import os
    import pandas
    import xlrd
    wb = xlrd.open_workbook('file.xlsx', logfile=open(os.devnull, 'w'))
  2. pd.read_excel(wb, engine='xlrd')
    UnboundLocalError: local variable 'pd' referenced before assignment

    Shouldn’t this be pandas.read_excel(wb, engine='xlrd')?

Comments are closed.