Search code examples
pythonexport-to-excel

Python to_excel not generating output file


I am trying to output a dataframe to an excel file. My code runs without any errors but there is no output file generated in the given directory (or elsewhere).

writer = pd.ExcelWriter("C:\\Users\\XXXXX\\OneDrive\\Membership\\merged_part.xlsx", engine='xlsxwriter', mode='w')
df_merged_part.to_excel(writer, sheet_name='Merged part')
writer.save()

I have checked the working directory and the rest of my PC for the files. I have uninstalled and re-installed Spyder (anaconda) in case it was the fact my laptop has recently upgraded to Windows 11 and there were any issues. Other threads have suggested variations on \ and " or r'; or using writer.save. No joy.


Solution

  • The issue was my AntiVirus (Comodo) was running Anaconda applications in a sandbox and refusing to write outputs.