Using ArcPy to Create a Geodatabase

This project involved creating a search cursor to find specific cities and populating a dictionary with their names and populations. Here’s a brief look at the steps I took and the problems I encountered!

First, I set the workspace to the required data folder and created a new file geodatabase. I then iterated over the list of feature classes and copied them to the new geodatabase.

I then created a search cursor to find cities listed as 'County Seat' and printed their details.

Finally, I aimed to populate a dictionary with the names and populations of these cities.

The step that gave me the most trouble was creating the search cursor to find the specific cities listed as 'County Seat' and then populating the dictionary with their names and populations. The problem I had was that after iterating through the cursor the first time to print the city details, I couldn't use the same cursor again to populate the dictionary. I wasn't getting any data in my dictionary. To fix it, I recreated the cursor before the second loop. So, instead of trying to reuse the same cursor, I created a new search cursor just for the dictionary part.
Another error I kept running into was I was trying to print the start and stop times for each geoprocessing task, but nothing was showing up. To get it to work, I took away the “count = arcpy.GetMessageCount()” part and added “print(arcpy.GetMessages())” after each process I wanted a timestamp with.
x

Comments