Чтение данных поля из Sharepoint с помощью Python — для многих полей отсутствует или отсутствует.Python

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Чтение данных поля из Sharepoint с помощью Python — для многих полей отсутствует или отсутствует.

Сообщение Anonymous »

Цель: чтение значений полей (столбцов) из библиотеки SharePoint.
Код приведен ниже. При печати «полей» отображаются все, но при печати «item.properties» отображаются только некоторые поля, многие из которых «Нет» (обязательно доступны в Интернете).[![screenshot][1]][1]
Дополнительная информация: как ни странно, этот код работает (т. е. показывает все значения полей) в другой библиотеке в той же точке доступа.
Спасибо!
from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.sharepoint.client_context import ClientContext

# Replace these variables with your SharePoint details
site_url = "https://xx.sharepoint.com/sites/xx"
username = "xx@xx"
password = r"xx"

# Authenticate and establish connection
ctx_auth = AuthenticationContext(site_url)
if ctx_auth.acquire_token_for_user(username, password):
ctx = ClientContext(site_url, ctx_auth)
print("Connection established successfully.")
else:
print("Authentication failed.")
# Specify the library name
library_name = "Reports"

# Get the library
library = ctx.web.lists.get_by_title(library_name)
ctx.load(library)
ctx.execute_query()

# Get all fields (columns) of the library
fields = library.fields
ctx.load(fields)
ctx.execute_query()

# Display column details
print("Columns in the Library:")
print(fields) # --> OK, all fields are listed

# Access items in the library
items = library.items.paged(50)
ctx.load(items)
ctx.execute_query()

items[0].properties # --> shows some of the fields, many of them are "None"

[1]: https://i.sstatic.net/pzIj0rBf.png


Подробнее здесь: https://stackoverflow.com/questions/792 ... any-fields
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Python»