1

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'])
1
  • I think Shareplum does not provide any API where you can download the actual file, instead it just provide the metadata information. Commented Sep 30, 2019 at 10:09

1 Answer 1

0

You may have a try below API to download files in the specified folder:

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

To download files:

folder.get_file('source.csv')

Test demo:

BR

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.