AnsweredAssumed Answered

Using a csv list of usernames to delete AGOL users

Question asked by Jeanine.Finn on May 20, 2019
Latest reply on May 24, 2019 by Jeanine.Finn

Hello - I've been working on writing some scripts to help clean up our AGOL membership.


This community has been great - I've been using Richard Stokes question (and notebook) to help get started:


I'm running into some problems deleting a list of around 140 users based on a CSV file (our GIS group came up with a list of criteria and created and exported this list of usernames from AdminTools). It's a single column CSV with just usernames (the column heading is "Username").


As I understand it, I need get each user account, release their licenses, delete their content, and then delete the member. 


I seem to be doing something very basic incorrectly in my initial loop through the list of usernames to get each user account from AGOL.


#Import modules
from arcgis.gis import GIS
import csv


#Declare GIS
gis = GIS("", "adminName", "psswrd")


#Make list of users to delete
userDelete = []


with open(r"4_22_2019InactiveUsers2.csv") as f_input:
csv_input = csv.DictReader(f_input)
   for row in csv_input:
   users = row["username:Username")]

---------------------------------------------------------------------------TypeError                                 Traceback (most recent call last)<ipython-input-28-d415de218329> in <module>      2     csv_input = csv.DictReader(f_input)      3     for row in csv_input:----> 4         users = row["username:Username")]      5         userDelete.append(users)      6  TypeError: unhashable type: 'list'


Any suggestions appreciated - I'm new   Thank you!