We have the following use case:
Users are not able to input all data they need into our ERP system. So what they do is maintaining Excel files with that data. To do planning activities they want to combine their Excel data with ERP data (from the database) in yet another Excel file. They want to make comments in this file and they want it to be updated every day using the most recent data from the ERP system.
The solution that I envision is to use a Python script that gathers the Excel data at night, loads it to MS SQL, transforms it over there and then loads it back to SharePoint, replacing the old file if the process is successful.
The difficult part is accessing the Excel file on SharePoint. I wanted to use the Microsoft Graph API but was instead asked to use a Python library called Office365. Now I don't get along with the documentation too well so I will describe what I need in pseudo-code below and hope for your help.
Do you know a way in Python to achieve roughly the following?
import MagicLibrary as MagL
import pandas as pd
SHAREPOINT_USERNAME = "[email protected]"
SHAREPOINT_PASSWORD = "Password"
SHAREPOINT_URL = "Sharepoint URL"
SHAREPOINT_PATH = "Path to Document"
FILE_NAME = "NeededData.xls"
SHEET_NAME = "Sheet 1"
RANGE = "A1:D20"
SharePoint_Connection = MagL.Connection(SHAREPOINT_URL, SHAREPOINT_USERNAME, SHAREPOINT_PASSWORD)
Excel_Range = SharePoint_Connection.Path(SHAREPOINT_PATH).File(FILE_NAME).Sheets(SHEET_NAME ).Range(RANGE ).As_Pandas_Usable_Array
df = pd.to_dataframe(Excel_Range)
#Use SQL Alchemy below to write dataframe to MS SQL Server.
#Code
Alternatively, if the API is only able to get into SharePoint, but not into Excel, I would also be fine with loading the Excel file to the server that executes the script and then accessing the file contents there, using Pandas.