Office365-REST-Python-Client icon indicating copy to clipboard operation
Office365-REST-Python-Client copied to clipboard

Error when trying to read items from Sharepoint folder that containing more than 5000 files

Open adornodev opened this issue 2 years ago • 3 comments

Hi,

I'm trying to read files (e.g: filename, file content) from a Sharepoint folder that containing more than 5000 items.

Part of my code is shown below:

 def get_filenames(self, relative_folder_url:str)->List[str]:
        folder = self.context.web.get_folder_by_server_relative_url(relative_folder_url)
        files = folder.files
        self.context.load(files)
        self.context.execute_query()
        return [file.name for file in files]

However, no list has been created on my Sharepoint.

The items are children of a folder created inside the "Form" component (a folder in Shared Documents section).

Example of the folder url:

https://xxxxxxx.sharepoint.com/teams/yyyyyy/Shared%20Documents/Forms/AllItems.aspx?id=/teams/yyyyyy/Shared%20Documents/Terceira%20Versão/GDT or (it has the same response) https://xxxxxxx.sharepoint.com/teams/yyyyyy/Shared%20Documents/Terceira%20Versão/GDT

The code above works in any folder containing less than 5000 items. I've read about #558 and #392 but there it's about items from List resource. It's not my case. I don't use "self.context.web.lists".

How can I change the code to works with large folders (>5000) without works with List? I'm using the version 2.3.16.

Thanks in advance, Lucas.

adornodev avatar Jan 17 '23 21:01 adornodev