Greetings,
The script query returns items from Portal, the query doesn't recognise Item_Type??
The aim is to return a Feature Collection and associated Layers, this might be 1 or might be 10. I find it odd that I would have to use an IF loop to return the Feature Type
all_users = portal.users.search(max_users = 700) # The default of max_users = 100
#groups = portal.groups.search(query='owner:*', max_groups=50)
#groups = portal.content.search(query='owner:*', item_type='Feature*')
groups = portal.groups.search('title:*', max_groups=50)
## output file
outFile = (r"C:\Users\users\Documents\local\Programme\GIS Data Catalogue\GIS_Items.csv")
with open(outFile, 'w') as csvfile:
filewriter = csv.writer(csvfile, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL)
filewriter.writerow(['group_id', 'group_title', 'group_owner', 'item_id', 'item_title', 'item_type', 'item_owner'])
for group in groups:
# ### Prints the Group Name + Owner
# #print(group.title, group.owner)
for user in all_users:
#print(group.id, group.title, group.owner)
#### List the Items in Portal
content_item = user.items()
for item in content_item:
#print(group.id, group.title, group.owner, item.id, item.title, item.owner)
rowitem = (group.id, group.title, group.owner, item.id, item.title, item.type, item.owner)
filewriter.writerow(rowitem )
## outFile.close
print("END")
Appreciate any pointers.
Regards,
Clive
I added an IF loop to try and remove files.
if item.url != "None":
The != "" or != "None" doesn't have any effect??
Hi Clive,
Could it be that you want to check for python's None type rather than the string "None"?
maybe try:
if item.url != None:
or maybe even:
if item.url != None or item.url != "": # to also capture empty strings
also, I could be wrong but you won't need the parentheses around your csv path. If it still works for you then thats alright.
## output file
outFile = r"C:\Users\users\Documents\local\Programme\GIS Data Catalogue\GIS_Items.csv"
hth
In case this is not clear.
I have a number of Feature Serveries that have layers that I want to interrogate/return and loop through. I return the Feature Service, but can't return the Layers??