python - 如何从共享点上的给定文件夹中读取文件名
问题描述
我正在 python 2.7 中编写一个工具,它可以自动化我的 ETL,它将在循环中读取共享点中的文件并转换为数据帧。我的 ETL 已完成,但我无法从 sharepoint 上可以提供我的 ETL 的文件夹中读取文件名。任何帮助表示赞赏。提前致谢
我检查了 context.web 的类成员,我可以看到 get_folder_by_server_relative_url
import os
from office365.sharepoint.caml_query import CamlQuery
from office365.runtime.auth.authentication_context import
AuthenticationContext
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.file import File
from office365.sharepoint.file_creation_information import
FileCreationInformation
import inspect
url= "https://XXX.sharepoint.com/sites/XXX/"
username = "blah@xxx.com.au"
password = "blah123!"
ctx_auth = AuthenticationContext(url=url)
if ctx_auth.acquire_token_for_user(username=username,password=password):
context = ClientContext(url, ctx_auth)
print(inspect.getmembers(context.web))
lists = context.web.get_folder_by_server_relative_url('Shared Documents/ELZ/')
items = lists.Folders
context.Load(items)
context.ExecuteQuery()
folder = GetListItemFolder(item)
for item in items:
print "File name: {0}".format(item.properties["Name"])
AttributeError:“FolderCollection”对象没有属性“get_folder_by_server_relative_url”
解决方案
推荐阅读
- winapi - 访问物理内存地址
- c++ - Visual Studio C++ 2019,破碎不详细的智能感知
- excel - 以日期列为条件的 MAXIFS
- r - 使用 ggcompetingrisks 将审查形状添加到累积发生率图中
- javascript - 找不到模块'../../../../utils/Postgres'
- android - java.lang.ref.FinalizerReference.add (FinalizerReference.java:61) 的 TimeoutException
- postico - Postico 中创建的数据库保存在 Mac 上的什么位置?
- regex - 如何根据带有异常的正则表达式删除一行
- python - PyInstaller 和 Py2exe 不适用于 python 3.9?
- java - 在创建休眠实体时是否总是需要有一个对象属性而不仅仅是 id?