Merge two data sets with conditions for field placement

04-09-2020 03:47 PM
New Contributor III

I am attempting to merge two different datasets and need some direction.

The feature (Incident) I have has the following fields:

Incident Number, date and call processing, unit1, raction1, travel1, unit2, reaction2, travel2, .......

I want to merge a table (Unit) with the following information:

Incident number, Unit, Reaction, Travel, and sequence.

I want to take the table and place the information that equals the incident number and place the information into the appropriate field for the units.

Tried using field calculation to come up with a python script, but for the life of me I can't think how to get this done. I tried the following but i keep getting errors.

#Field =
answer(!UnitData.Apparatus_Name!, !UnitData.Sequence!)

#Code Block
def answer(unit, seq):
if seq == 2:
return unit
return None

In the long run, I want to be able to create a script to run to merge the data automatically to populate the data into a single field.

Thanks for the thoughts...

0 Kudos
1 Reply
MVP Esteemed Contributor

Sounds more like you want to do a join, based on the Incident number as the common field between the two. Sounds like a process for Richard Fairhurst‌'s classic dictionary approach:  /blogs/richard_fairhurst/2014/11/08/turbo-charging-data-manipulation-with-python-cursors-and-diction... 

That should just about do it....
0 Kudos