Home > Enterprise >  Data won't export to excel file
Data won't export to excel file

Time:01-19

I have a dataframe I'm trying to export to an excel file that lives on my company's SharePoint. I've mapped a network drive to the folder where the file is and used the following code to write to it:

df.to_excel(r'C:\Users\Name\AppData\Roaming\Microsoft\Windows\Network Shortcuts\companyname.sharepoint.com\Copy_Material Flow for XXX.xlsx', sheet_name='Sheet1', index = False)

However, it's not writing anything to Sheet1 for some reason. Anyone know why this could be?

CodePudding user response:

the problem could be the 'r' in r'path', try this:

df.to_excel("C:\\Users\\Name\\AppData\\Roaming\\Microsoft\\Windows\\Network Shortcuts\\companyname.sharepoint.com\\Copy_Material Flow for XXX.xlsx", sheet_name='Sheet1', index = False)

CodePudding user response:

Try removing the space from the filename first:

df.to_excel(r'C:\Users\Name\AppData\Roaming\Microsoft\Windows\Network Shortcuts\companyname.sharepoint.com\Copy_MaterialFlowforXXX.xlsx', sheet_name='Sheet1', index = False)

Try removing the regular expression, r, from the string type

df.to_excel('C:\Users\Name\AppData\Roaming\Microsoft\Windows\Network Shortcuts\companyname.sharepoint.com\Copy_MaterialFlowforXXX.xlsx', sheet_name='Sheet1', index = False)
  •  Tags:  
  • Related