Assign Field values via Python

Discussion created by moswitch on Oct 27, 2012
Latest reply on Oct 28, 2012 by moswitch

I am attempting to calculate point stationing (footage) along a pipeline at a set interval via python script.  Thing is I'm just now learning to code in Python, I have a VBA programming background.  In regards to this exercise I will be creating an empty file geodatabase, within this database I will be creating an empty feature class.  This feature class will contain an empty field/column named, "Calculated Footage".

I have been successful in obtaining the desired results within a python list as shown below but when attempting to do so in a file geodatabase I seem to be at a lost. Simply put how do I go about applying the logic below to the "Calculated Footage" field in my feature class table? In other words how do I populate the "Calculated Footage" field with the result of my while loop?

B_Measure = 0; E_Measure = 5280
Curr_Measure = 0; Interval = 1000

C_Measure = 0

# Body of the Main program
while abs(E_Measure-C_Measure)>Interval:
    if My_List==[]:
        print C_Measure
        C_Measure=C_Measure + Interval
        print C_Measure

I've done this exercise in Excel as well, using the following VBA Code.

Sub Calculate_Footage()
'Declaring variables
Dim X, Y, Beginning_Point, Ending_Point, Interval, Current_Point As Integer

'Assigning initial value to variables
X = 2
Y = 1
Beginning_Point = 0
Ending_Point = 5280
Interval = 1000
Current_Point = 0

'Assign Field/Column Name
Cells(1, 1).Value = "Calculated Footage"

'This While Loop will populate my "Calculated Footage" field
Do While (Ending_Point - Current_Point) > Interval
Current_Point = Current_Point + Interval
Cells(X, Y).Value = Current_Point

'Move to the next row but same column
X = X + 1

End Sub