Maintained. Last release 5 months ago, commits in 1 of the last 26 weeks. Weaker on commit activity and release cadence.
pip install msgraphfsFilesystem interface to Microsoft Graph API (SharePoint, OneDrive)
Quickstart
This package can be installed using:
pip install msgraphfs
or
uv add msgraphfs
The msgd://, sharepoint://, and onedrive:// protocols are included in fsspec's known_implementations registry, allowing seamless integration with fsspec-compatible libraries.
To use the filesystem with specific site and drive:
import pandas as pd
storage_options = {
'client_id': 'your-client-id',
'tenant_id': 'your-tenant-id',
'client_secret': 'your-client-secret',
'site_name': 'YourSiteName',
'drive_name': 'Documents'
}
df = pd.read_csv('msgd://folder/data.csv', storage_options=storage_options)
To use multi-site mode where site and drive are specified in the URL:
import pandas as pd
storage_options = {
'client_id': 'your-client-id',
'tenant_id': 'your-tenant-id',
'client_secret': 'your-client-secret'
}
df = pd.read_csv('msgd://YourSite/Documents/folder/data.csv', storage_options=storage_options)
df = pd.read_parquet('sharepoint://AnotherSite/Reports/data.parquet', storage_options=storage_options)
Accepted protocol / uri formats include:
msgd://site/drive/path/file(multi-site mode)sharepoint://site/drive/path/file(multi-site mode)onedrive://drive/path/file(OneDrive personal)msgd://path/file(single-site mode when site_name and drive_name specified in storage_options)
To read files, you can optionally set the MSGRAPHFS_CLIENT_ID, MSGRAPHFS_TENANT_ID, and MSGRAPHFS_CLIENT_SECRET environment variables, then storage_options will be read from the environment:
import pandas as pd
# With environment variables set, you can omit credentials from storage_options
storage_options = {'site_name': 'YourSite', 'drive_name': 'Documents'}
df = pd.read_csv('msgd://folder/data.csv', storage_options=storage_options)
Details
The package provides a pythonic filesystem implementation for Microsoft Graph API drives (SharePoint and OneDrive), facilitating interactions between Microsoft 365 services and data processing libraries like Pandas, Dask, and others. This is implemented using the base class and Microsoft Graph Python SDK.