I am using xlrd to process Excel files. I am running a script on a folder that contains many files, and I am printing messages related to the files. However, fo
The answer by John works, but has a small problem:
xlrd writes that warning message and the following newline character separately to the logfile. Therefore you will get an empty line in your stdout instead of the message, if you use the filter class proposed by John. You shouldn't simply filter out all newlines from the log output either though, because there could be "real" warnings that would then be missing the newlines.
If you want to simply ignore all log output by xlrd, this is probably the simplest solution:
book = xlrd.open_workbook("foo.xls", logfile=open(os.devnull, 'w'))