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?
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)
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.