我正在尝试使用通过anaconda安装的适用于python的dropbox api从远程(非本地)dropbox文件夹读取所有文件的路径。此文件夹上有50,000个文件,包括子文件夹中的一些文件。我正在从子文件夹中获取文件。但是,返回的总结果似乎限制在2001年。如何返回所有50,000个文件的路径?
dbx = dropbox.Dropbox(access)
results = dbx.files_list_folder(dbx_path_check, recursive=True)
dbx_files = list(i.path_display for i in results.entries)
print(len(dbx_files))
2001
答案 0 :(得分:1)
我不确定在保管箱Api中是否有所不同。你尝试过这样的事情吗?
import os
dbx_files = []
for root, dirs, filenames in os.walk(your_directory):
dbx_files.append(os.path.join(root,filename))
print(len(dbx_files))
答案 1 :(得分:-1)
#Connect to the SQL database
import pyodbc
import os
import json
import glob
from pathlib import Path
import datetime as dt
import string
import dropbox
#Connect to the DB
cnxn = pyodbc.connect('Driver={SQL Server};Server=atabase=;Trusted_Connection=yes;')
print("Connection established")
cnxn.timeout = 60
cnxn.autocommit = True
cursor = cnxn.cursor()
dbx = dropbox.Dropbox("")
result = dbx.files_list_folder("", recursive=True, include_deleted=False, include_media_info=False)
def process_entries(entries):
for entry in entries:
if isinstance(entry, dropbox.files.FileMetadata):
#print(entry.name)
md, res = dbx.files_download(entry.path_lower)
json_obj = json.loads(res.content)
al_data = json.dumps(json_obj)
.
.
.
#Insert values into the DB
cursor.execute("INSERT INTO dbo.audiolink_table_1 (...)
process_entries(result.entries)
# Check if there are more files in the folder
while result.has_more:
result = dbx.files_list_folder_continue(result.cursor)
process_entries(result.entries)