[GIS] Updating Multiple Fields in Feature Class from a Table

arcgis-desktopattribute-tablefeature-classpythonupdate

I have a Point Feature Class with 2 million records with 35 fields. I have another csv file (contain 25 fields) which have around 4000 records to update certain records of the Point Feature Class . Within these 4000 records, only around 70 are matched with the common field which is the Account ID and among these records the fields are needed to be updated. There are more than 20 fields that will be needed to update. I am trying to automate this process of updating the fields of the match records.

Currently, I am trying to use write Python Script to update the fields. I am still very new to Python and have no programming background thus I am having problems with my script.

My workflow is this:

  1. Convert the csv file to Table in gdb
  2. Join (AddJoin) the Table to Point Feature Class.

Then, I am trying to use UpdateCursor which has failed ever since I tried.

If I am using ModelBuilder, I can use Field Calculator tools to change each of the field but I think it will take a long time and it does not seem to be a very nice way of updating the fields.

I am not sure if there is easier way of updating the fields in the Point Feature Class from the given csv files.

Best Answer

First, let it be known there are a number of ways someone could go about accomplishing roughly the same goal in this case. For me personally, especially for someone less experienced with arcpy, it would likely be simplest to do roughly the following workflow

  1. Convert the CSV file to Table in GDB
  2. Join the Table to Point Feature Class
  3. Make Feature Layer (geoprocessing tool, allows for selections to be applied)
  4. Select by attribute against layer to select only those features that need updating (ex: select where JoinTable.OID IS NOT NULL)
  5. Calculate field against the selected layer for each field needing updated.

By first making sure you have a selection applied, it shouldn't take too long to run through 70 or so records. I will admit, yes, it would be quicker and more efficient to use cursors to accomplish this, assuming you are at 10.1 or higher and have access to the arcpy.da cursors. But, for simplicity sake and ease of use, calculate field isn't a terrible option.