Hello,
I am writing a script and a portion of said script requires that I build a table that starts at 0 and increments by 1 until reaching the value of "Shape_Length" from a feature class. I have line work that I wish to read the "Shape_Length" from and I am having troubles getting the syntax correct.
Route <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>CreateRoutes_lr<SPAN class="punctuation token">(</SPAN>Input_Linework<SPAN class="punctuation token">,</SPAN> Linework_Field<SPAN class="punctuation token">,</SPAN> Output_Name<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Store value in SHAPE_LENGTH from Route</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>Route<SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'Shape_Length'</SPAN><SPAN class="punctuation token">]</SPAN><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>
Max_Value <SPAN class="operator token">=</SPAN> row<SPAN class="punctuation token">.</SPAN>getValue<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Shape_Length'</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">del</SPAN> row
<SPAN class="keyword token">del</SPAN> cursor
<SPAN class="comment token"># Create table with two fields, RouteID and Chainage</SPAN>
Route_Table <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>CreateTable_management<SPAN class="punctuation token">(</SPAN>str<SPAN class="punctuation token">(</SPAN>Output_WS<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> Output_Name<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Append additional rows to table in increments of 1 and end at the exact value of</SPAN>
<SPAN class="comment token"># the Max_Value</SPAN>
fields <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'RouteID'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Chainage'</SPAN><SPAN class="punctuation token">]</SPAN>
Pop_Table <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>InsertCursor<SPAN class="punctuation token">(</SPAN>Route_Table<SPAN class="punctuation token">,</SPAN> fields<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> x <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> Max_Value<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
Pop_Table<SPAN class="punctuation token">.</SPAN>insertRow<SPAN class="punctuation token">(</SPAN>str<SPAN class="punctuation token">(</SPAN>Linework_Field<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> x<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">del</SPAN> x<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>I get an error on line 6:
AttributeError: 'tuple' object has no attribute 'getValue'
I have tried reading through the page:
Accessing data using cursors—Help | ArcGIS Desktop
I messed around with the code a bit but this is where I am at now and can't determine how to move forward.