HOW TO
In an organization, managing and administrating large number of items stored within Portal for ArcGIS and ArcGIS Online can be time-consuming. To simplify this process using ArcGIS API for Python, the following steps describe how to generate a report of all items in Portal for ArcGIS or an ArcGIS Online organization.
Choose one of the following scripts below.
Generate the report for all items in Portal for ArcGIS
from arcgis import GIS import pandas as pd
gis = GIS('<machine>.<domain>/<web adaptor name>', 'username', 'password', verify_cert=False) print("Connected")
content_list = gis.content.search('owner:<Owner_Name>', max_items=-1)
out_dict = {} for item in content_list: out_dict[content_list.index(item)] = [item.title, item.type, item.numViews, item.owner, item.id] df = pd.DataFrame.from_dict(out_dict, orient='index') df.rename(columns={0:'title', 1:'type', 2:'views', 3:'owner', 4:'id'}, inplace=True)
df.to_csv(r'<Folder Location>')
The following code block demonstrates the full script.
from arcgis import GIS import pandas as pd gis = GIS('machines.esri.com/portal', 'username', 'password', verify_cert=False) print("Connected") content_list = gis.content.search('owner:Test_User', max_items=-1) type, owner, id, etc. out_dict = {} for item in content_list: out_dict[content_list.index(item)] = [item.title, item.type, item.numViews, item.owner, item.id] df = pd.DataFrame.from_dict(out_dict, orient='index') df.rename(columns={0:'title', 1:'type', 2:'views', 3:'owner', 4:'id'}, inplace=True) df.to_csv(r'C:\Users\USER\Desktop\TestListReport.csv')
Generate the report for all items in ArcGIS Online
from arcgis import GIS import pandas as pd
gis = GIS('https://arcgis.com', 'username', 'password') print("Connected")
content_list = gis.content.search('owner:username', max_items=-1)
out_dict = {} for item in content_list: out_dict[content_list.index(item)] = [item.title, item.type, item.numViews, item.owner, item.id] df = pd.DataFrame.from_dict(out_dict, orient='index') df.rename(columns={0:'title', 1:'type', 2:'views', 3:'owner', 4:'id'}, inplace=True)
df.to_csv(r'<Folder Location>')
The following code block demonstrates the full script.
from arcgis import GIS import pandas as pd gis = GIS('https://arcgis.com', 'username', 'password') print("Connected") content_list = gis.content.search('owner:Test_User', max_items=-1) out_dict = {} for item in content_list: out_dict[content_list.index(item)] = [item.title, item.type, item.numViews, item.owner, item.id] df = pd.DataFrame.from_dict(out_dict, orient='index') df.rename(columns={0:'title', 1:'type', 2:'views', 3:'owner', 4:'id'}, inplace=True) df.to_csv(r'C:\Users\USER\Desktop\TestListReport.csv')
Get help from ArcGIS experts
Download the Esri Support App