Lab 5: Exploring & Manipulating Data

This week's lab we created a script including search cursors, lists, and dictionaries. Below is the results for the script I created including output messaging:

First, I used import arcpy, import os, created base directory and the folder where all results would be stored. Then, I constructed the full paths to the results folder, to the source data folder, and finally to the new file geodatabase. Throughout the script, I included the GetMessages function and print functions for output messages. 


After creating the file geodata base, I set the workspace to the source data folder to begin listing its contents using the ListFeatureClasses() function. Once the path to the input feature class was created, I used the CopyFeatures_management function to copy the feature class. 


Next, I set the workspace to the new file geodatabase to perform a Search Cursor on the cities feature class. I defined the fields for the Search Cursor to retrieve then used arcpy.da.SearchCursor () function to print the retrieved rows included the city name, county seat, and population. 
The last task of the lab was to create a dictionary for the county seats. Below is the populated county seats dictionary with the city name and population. 

This was the most complex lab I've done so far so my flowchart is very long! In the script, I also included print Error messages and used the Execute Error messages to catch all the errors that I had while building the script. I did have mostly invalid syntax errors and unexpected indentation errors throughout this process. 

Comments