Hello,
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:
https://stackoverflow.com/questions/7619319/python-xlrd-suppress-warning-messages
But that would require having access to specify the logger in the read_excel function arguments.
Or is there another solution ?
Thanks,
Loic
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'))
pd.read_excel(wb)
It does the trick for me!
Thanks a lot for helping
pd.read_excel(wb) could not read wb.
Pls forgive the necrobumping here :skull_and_crossbones::fist_left:
update for 2019:
import os
import pandas
import xlrd
wb = xlrd.open_workbook('file.xlsx', logfile=open(os.devnull, 'w'))
pd.read_excel(wb, engine='xlrd')
pd.read_excel(wb, engine='xlrd')
UnboundLocalError: local variable 'pd' referenced before assignment
Shouldn't this be pandas.read_excel(wb, engine='xlrd')?
The solution provided above redirects standard error outputs to null device,
import os
import pandas as pd
import xlrd
wb = xlrd.open_workbook('file.xlsx', logfile=open(os.devnull, 'w'))
pd.read_excel(wb, engine='xlrd')
Most helpful comment
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_excelwork for you?Something like