*EDIT*
I marked Joshua Bixby's response as the correct answer as it solved the original issue I had, but I also want to give a special thanks to Dan Patterson for helping me figure out the tuple issue. Thanks for everyone else for chiming in as well. Much appreciated! Please reference the final working script at the bottom of this request.
Hello, I have working scripts that use UpdateCursor and InsertCursor, but all of my previous work has been in the fashion of inserting or updating records in the feature class or table that I am referencing. I'm struggling to figure out how to reference data in one feature class, and then insert entries using that information into a separate database table. I'm pretty confident that the problem I am having is very basic, but I am no expert in Python and I'm obviously missing something. Basically I want to take every entry in a feature class, and then depending on a user input, enter X number of entries into a related table for each feature in the feature class.
So say the number of features in the feature class is 10, and the user states that we need 2 records in the related table for each site, then I need the script to create 20 entries. In those 20 entries, though, I need for the script to take a number of fields from the feature class, and port them over into the appropriate fields in the related table entries.
<SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>UpdateCursor<SPAN class="punctuation token">(</SPAN>inTable<SPAN class="punctuation token">,</SPAN> inField<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> cursor<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> cursor<SPAN class="punctuation token">:</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> name
cursor<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">)</SPAN> <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
The above code is something I'm familiar with, but again, it's only referencing one feature class, so the inField variable represents fields that are contained within the inTable variable, obviously. How do I grab fields from a feature class, create entries in a table, and then populate some of the fields in those entries based on the feature class?
Working Script:
<SPAN class="keyword token">import</SPAN> arcpy
numIDs <SPAN class="operator token">=</SPAN> user_input <SPAN class="comment token"># user input variable</SPAN>
targetTBL <SPAN class="operator token">=</SPAN> target_table <SPAN class="comment token"># table that rows will be inserted into</SPAN>
targetFields <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">'SimpleID'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'ExtendedID'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'InternalID'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'ExternalID'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Termination'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'ProjectRegion'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'ProjectState'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'ProjectName'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'ProjectCustomer'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'NodeGUID'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'CircuitID'</SPAN><SPAN class="punctuation token">)</SPAN>
sourceFC <SPAN class="operator token">=</SPAN> source_table <SPAN class="comment token"># table that information comes from</SPAN>
sourceFields <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">'SimpleID'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'ExtendedID'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'InternalID'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'ExternalID'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Termination'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'ProjectRegion'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'ProjectState'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'ProjectName'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'ProjectCustomer'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'GlobalID'</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Execute Insert Cursor and Search Cursor</SPAN>
<SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>InsertCursor<SPAN class="punctuation token">(</SPAN>targetTBL<SPAN class="punctuation token">,</SPAN> targetFields<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> targetCursor<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN>sourceFC<SPAN class="punctuation token">,</SPAN> sourceFields<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> sourceCursor<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> sourceCursor<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> numIDs<SPAN class="operator token">+</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">if</SPAN> i <SPAN class="operator token"><</SPAN> <SPAN class="number token">10</SPAN><SPAN class="punctuation token">:</SPAN>
IDnumber <SPAN class="operator token">=</SPAN> <SPAN class="string token">"0"</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>i<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN>
IDnumber <SPAN class="operator token">=</SPAN> str<SPAN class="punctuation token">(</SPAN>i<SPAN class="punctuation token">)</SPAN>
InternalID <SPAN class="operator token">=</SPAN> row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN>
Termination <SPAN class="operator token">=</SPAN> row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">4</SPAN><SPAN class="punctuation token">]</SPAN>
Customer <SPAN class="operator token">=</SPAN> row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">8</SPAN><SPAN class="punctuation token">]</SPAN>
circuitID <SPAN class="operator token">=</SPAN> <SPAN class="string token">"({})-({})-({})-({})"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>InternalID<SPAN class="punctuation token">,</SPAN> Termination<SPAN class="punctuation token">,</SPAN> Customer<SPAN class="punctuation token">,</SPAN> IDnumber<SPAN class="punctuation token">)</SPAN>
targetCursor<SPAN class="punctuation token">.</SPAN>insertRow<SPAN class="punctuation token">(</SPAN>row <SPAN class="operator token">+</SPAN> <SPAN class="punctuation token">(</SPAN>circuitID<SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>