Importing Excel files into python is very simple:
-
Open the Excel file from the personal OneDrive. Go to File > Share > Embed.
-
In the next Embed dialogue, click on Generate.
-
In the Embed pane, refer to the Embed code box on the lower left-hand corner. Here you will find the embed iframe. Copy the iframe and paste it onto a text editor of your choice.
-
Within the iframe, locate the values for resid and authkey.
<iframe width="402" height="346" frameborder="0" scrolling="no" src="https://onedrive.live.com/embed?resid=YOURRESID&authkey=YOURAUTHKEY&em=2&wdAllowInteractivity=False&wdHideGridlines=True&wdHideHeaders=True&wdDownloadButton=True&wdInConfigurator=True"></iframe>
-
With these values, use pandas to read the file. Replace ‘YOURRESID’ and ‘YOURAUTHKEY’ with the values found in the previous step.
import pandas as pd resid = 'YOURRESID' authkey = 'YOURAUTHKEY' url_excel = ('https://onedrive.live.com/download?' + 'resid=' + resid + '&authkey=' + authkey + '&em=2&app=Excel') one_drive_df = pd.read_excel(url_excel)
Beware that this method works for Excel files in a personal OneDrive, not enterprise OneDrive