1 year ago

#362756

test-img

Ulewsky

Get .XLS file from outlook and open it in pandas

I have that problem that I'm getting on my outlook filename.XLS every one day in week and I wanted to download it, modify and save to .csv in some directory. The issue is that it is excel version 97-2003 and when I'm opening it there is a quote:

"The file format extension of 'filename.XLS' don't match. The file could be corrupted or unsafe...", when I choose that I want to open it everything is fine and I have to enable editing.

I was trying to do it in a different ways:

#First try
xlrd.open_workbook(filename, encoding_override='cp1252')

#Second one
os.rename('filename.XLS', 'filename.csv')
csv = pd.read_csv("filename.csv", error_bad_lines=False)

#Third
import win32com.client as win32
filename = "filename.XLS"
excel = win32.gencache.EnsureDispatch('Excel.Application')
wb = excel.Workbooks.Open(filename)

But any of them is not working.

I have checked an I have also possibility to have this file in .html file instead of .XLS but I didn't checked it so maybe it could be another way to solve it.

excel

pandas

outlook

xls

pywin32

0 Answers

Your Answer

Accepted video resources