stu9403

Use split field to update a new field

Discussion created by stu9403 on Apr 28, 2011
Latest reply on Apr 28, 2011 by stu9403
Hi all,

I am having problems with what should be something really simple.  I have a text field ("Start_Time") formatted as 11:23:40:60.  I am trying to split the text at ':' and write the first set to a new "Hour" field.  I can get the split to work but am having problems getting it into the "Hour" field.  I've tried it a couple of different ways and neither of them are working.  I've tried:
    UpCur = gp.UpdateCursor(InFC)
    row = UpCur.Next()
    while row:
        TimeList = row.Start_Time.split(":")
        hr = TimeList[0]
        row.setvalue("Hour", hr)
        row = UpCur.next()

and I've also tried:
    UpCur = gp.UpdateCursor(InFC)
    row = UpCur.Next()
    while row:
        row.Hour = row.Start_Time.split(":")[0]
        row = UpCur.next()


I must be missing something simple but can't figure it out.  I'm using ArcMap 9.3.1 and python 2.5.  Thanks in advance.

Stu

Outcomes