2

I am trying to pull data from a view I made in SharePoint and the connection works and the data is pulled but only 7 of the 10 columns are being returned. I tried both a normal GetListItems and also using field names.

I tried different views and the ALL view and I am only getting a 7 rows. It is odd. I wonder if there is something I am missing here?

Update:

Turns out that SharePoint List has a column character limitation to 32 characters. Maybe that is causing the problem as one of the column names is for sure over 32 characters. The other columns that are missing do not appear to be over this limit so maybe not the issue but worth mentioning just in case.

import shareplum as sp
from requests_ntlm import HttpNtlmAuth


auth = HttpNtlmAuth('domain\\user', 'password')
fields = ['ID', 'Task Status', 'Start Date', 'Originator of Request', 'Modified By', 'Modified',
          'Final Date', 'Impacted Systems', 'Assigned To', 'Number of']
site = sp.Site('https://url.com/sites/sitename', auth=auth)
sp_list = site.List('Group tasks')
data = sp_list.GetListItems('DashData', fields=fields, row_limit=1)

headers = []
row_data = []
print(data[0])
for key, value in data[0].items():
    print(key)

All I get is:

ID
Task Status
Start Date
Originator of Request
Modified By
Modified
Number of

I check the documentation on shareplum but I was not able to find any info on this behavior.

Mike - SMT
  • 14,784
  • 4
  • 35
  • 79
  • 1
    Ive been having this issue for the last day or two and ive been pulling my hair out. It looks like shareplum only brings across items for each row that are not null. So if an entire column is null, that column doesnt come over. – fuzzygwalchmei Apr 07 '21 at 22:21

2 Answers2

0

I have the same problem and I am still working on it. My idea is to create an empty dataframe with the structure of the Sharepoint list and then fill it with the data coming from the list.

df_schema = pd.DataFrame(SPSlistobj.list.fields)
list_out = SPSlistobj.list.GetListItems(fields=dfschema['DisplayName'].tolist())
df_out = df_out.append(list_out)
Flair
  • 2,609
  • 1
  • 29
  • 41
-1

Shareplum's GetListItems(), by default, omits the column where the value is NULL/empty for that particular row. This behaviour is justified since the returned type is a list of dictionaries and dictionaries cannot have keys with no values.

Hence, if data is not present for a column, you'll not be able to see them in the output.

  • Your assumption that **data is not present for a column** is incorrect. This issue was resolved a long time ago by using a different tool to pull the data. All 10 columns I mentioned have valid data in it so your speculation on NULL rows has absolutely nothing to do with only 7 of the columns being returned. – Mike - SMT Aug 05 '22 at 12:24