So I am trying to create an excel document that list all of my feature services / feature collections and what specific maps they are in, so far I have this, but when it runs it lists all my services in Column A, but then Column B is blank, any idea what could be happening? I am very new to python. Any help would be appreciated.
import arcgis
import openpyxl
# Set the URL of your ArcGIS Online portal
portal_url = 'https://yourportal.arcgis.com'
# Set your ArcGIS Online username and password
username = 'your_username'
password = 'your_password'
# Connect to the portal
gis = arcgis.GIS(portal_url, username, password)
# Search for all feature services and feature collections in the portal
items = gis.content.search(query='type: "Feature Service" OR type: "Feature Collection"', max_items=5000)
# Create a new Excel workbook
workbook = openpyxl.Workbook()
worksheet = workbook.active
# Add a header row to the worksheet
worksheet.append(['Feature Service/Collection', 'Maps Using Feature'])
# Iterate through the feature services and feature collections
for item in items:
# Search for maps in the portal that use the feature service or feature collection as a layer
maps = gis.content.search(query=f'type: "Web Map*" AND layers: {item.id}', max_items=5000)
# Create a list of the map names
map_names = [map.title for map in maps]
# Add a row to the worksheet with the feature service/collection name and the list of map names
worksheet.append([item.title, *map_names])
# Save the workbook to a file
workbook.save('feature_services_maps.xlsx')