Skip to content
Advertisement

How to import documents into python?

I have several unstructured data stored in sharepoint and I want to import them into python environment to do text classification.

However, I am not sure how to achieve this. I found a library called sharepoint (from sharepoint import SharePointSite, basic_auth_opener) but not exactly sure how to use it to read in files into python.

I couldn’t find any useful resource to achieve this. Can anyone please help me on this, or direct me to any sources where there is an example of doing the same thing?

Advertisement

Answer

@user86907,

I recommend a python library ‘shareplum’ for SharePoint, it’s easy to connect to SPO/SP server and fetch list/library data.

Download file:

from shareplum import Site
from shareplum import Office365
from shareplum.site import Version

authcookie = Office365(base_path, username=username, password=password).GetCookies()
site = Site('https://my.sharepoint.com/sites/s01',version=Version.v365, authcookie=authcookie)

folder = site.Folder('Shared Documents/This Folder')
folder.get_file('source.txt')

BR

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement