Final Project Read from a csv file and write to a database table: Prepare a Flood Insurance Rate Map (FIRM) database related to a hydraulics study for Federal Emergency Management Agency (FEMA) Flood Insurance Study (FIS) Introduction to GIS Programming Submitted By: Bibek Joshi Email Address: bibek.joshi@gmail.com 05/16/2014 SUMMARY This python script creates a personal geodatabase and adds a set of feature classes (point, polyline and polygon) and a database table. Python dictionary is used to store the name and type of feature classes and to store the name and type of fields. The script then reads from a comma-separated value (csv) file and writes the data into the database table. PURPOSE FEMA publishes flood hazard map to support the National Flood Insurance Program (NFIP). The data are summarized in Flood Insurance Study (FIS) and the maps are knows as Flood Insurance Rate Maps (FIRMs). There are normally three major phases to a FEMA flood study of a stream: i) determine stream discharges, ii) determine flood elevation and iii) map the floodplain. Phase i) and ii) are known as hydrologic and hydraulic (H&H) study phase. After each phases of the study, the deliverables include spatial files that have to follow certain guidelines. The guidelines for the GIS files submitted as a part of the H&H study are outlined in the FIRM Database Technical Reference Document. GEOPROCESSING TASKS Following arcpy functions were used: AddError AddField_management AddMessage CreateFeatureclass_management CreateFeatureDataset_management CreateFileGBD_management CreateTable_management Delete_management Exists GetMessage InsertCursor DIFFICULTIES/ ISSUES The following difficulties were encountered: The order in which the items in the Python dictionary are stored are different from the order in which the items are printed. So, in order to print the items in the same order collections.OrderedDict() function was used. Initially the script could not write to a field type "DOUBLE" or any other non-string data type. In the csv file the first row contains column header and the data were populated from the second row. In the script, if-statement was used to add the rows starting from the second row. However, when the values from the csv file are first read into each field, a field with double type cannot store the header name which is a string. As a result, Python produced an error message stating incompatible data type. This issue was resolved by 'consuming' the first row in the csv file using next() function. Another option to resolve this issue is to use csv.DictReader function. This is a unresolved issue: I could not find a function/process to convert a string into a variable name. I have stored the name of the fields as a string in a dictionary. When a new row is created and a value is assigned as in, irow.FIELDNAME = "", I was planning to use a loop to read from a dictionary for the FIELDNAME. However, 'FIELDNAME' has to be a variable and not a string. OUTCOME In the fully developed form of this script, the script will automatically create a file geodatabase with multiple feature classes that has a user-selected projection system. Each feature class and database table will have multiple fields created based on a specific guideline. Then the script will automatically read from a csv file and populate the database table.