Im trying to find if a .xlsx file contains a @. I have used pandas, which work great, unless if the excel sheet have the first column empty, then it fails.. any ideas how to rewrite the code to handle/skip empty columns?
the code:
df = pandas.read_excel(open(path,'rb'), sheetname=0)
out = 'False'
for col in df.columns:
if df[col].str.contains('@').any():
out = 'True'
break
This is the error i'm getting:
df = pandas.read_excel(open(path,'rb'), sheetname=0)
File "/anaconda3/lib/python3.6/site-packages/pandas/io/excel.py", line 203, in read_excel
io = ExcelFile(io, engine=engine)
File "/anaconda3/lib/python3.6/site-packages/pandas/io/excel.py", line 258, in __init__
self.book = xlrd.open_workbook(file_contents=data)
File "/anaconda3/lib/python3.6/site-packages/xlrd/__init__.py", line 162, in open_workbook
ragged_rows=ragged_rows,
File "/anaconda3/lib/python3.6/site-packages/xlrd/book.py", line 91, in open_workbook_xls
biff_version = bk.getbof(XL_WORKBOOK_GLOBALS)
File "/anaconda3/lib/python3.6/site-packages/xlrd/book.py", line 1271, in getbof
bof_error('Expected BOF record; found %r' % self.mem[savpos:savpos+8])
File "/anaconda3/lib/python3.6/site-packages/xlrd/book.py", line 1265, in bof_error
raise XLRDError('Unsupported format, or corrupt file: ' + msg)
xlrd.biffh.XLRDError: Unsupported format, or corrupt file: Expected BOF record; found b'\x17Microso'