Return Feature Collection and Layers

12-03-2020 06:36 AM
New Contributor III


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 = = 700)  # The default of max_users = 100
#groups ='owner:*',  max_groups=50)
#groups ='owner:*',  item_type='Feature*')
groups ='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.title, group.owner)
            #### List the Items in Portal
            content_item = user.items()
            for item in content_item:
                #print(, group.title, group.owner,, item.title, item.owner)
                rowitem = (, group.title, group.owner,, item.title, item.type, item.owner)
                filewriter.writerow(rowitem )

## outFile.close





Appreciate any pointers.



Tags (3)
0 Kudos
3 Replies
New Contributor III

I added an IF loop to try and remove files.

if item.url != "None":


The != "" or != "None" doesn't have any effect??

0 Kudos
Esri Contributor

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"




New Contributor III

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??

0 Kudos