Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
edited tags
Link
Ganesh Sanap - MVP
  • 46.4k
  • 22
  • 31
  • 63
Source Link

Not able to access content of sharepoint folders using shareplum [Python]

I've asked this question on stackoverflow too, here. But someone told me I'd have better luck on sharepoint stackexchange.

I'm trying to download a few csv files that reside in a document thats part of a sharepoint list. Sharepoint is not on-premise therefore requires O365 Auth.

My code till now:

in[1]: from shareplum import Site
       from shareplum import Office365

       authcookie = Office365('https://my.sharepoint.com', 
       username='username', password='password').GetCookies()
       site = Site('https://my.sharepoint.com/sites/documentLibrary/', 
       authcookie=authcookie)

       sp_list = site.List('listName')
       sp_list.GetListItems('All Documents')

out[1]: [{'Name': 'Folder1',
          'Modified': datetime.datetime(2019, 1, 30, 12, 7, 24),
          'Modified By': 'Jane Doe'},
        {'Name': 'Folder2',
         'Modified': datetime.datetime(2018, 11, 13, 16, 2, 41),
         'Modified By': 'Dane Joe'}]

So I'm able to get folder information about the files present in list by using GetListItems('All Documents').

Folders 1 and 2 are a part of the list. The csv files I want to downloads are in folder 1. I am not able to find a way to list any files from folder 1 and download them.

I've already tried the following:

in[2]: sp_list.GetListItems('Folder 1')
out[2]: KeyError: 'Folder 1'

The documentation isn't very clear, I do not get what the following does or is used for:

sp_data = new_list.GetListItems(fields=['ID', 'Title'])