Combine two columns into one

749
4
03-17-2011 06:56 AM
BartłomiejStaroń
New Contributor III
I want to create a script that will combine two columns into one.
Unfortunately, I have a problem with the??? "None" value.
I don't know how to verify the other value from  2 column.
I have something like this:

cursor = gp.UpdateCursor("FC")
row = cursor.Next()
while row:
      if ( row.field == None):
       pass
      else:
       row.fieldoutput = row.field + row.field2
       cursor.UpdateRow(row)
      row = cursor.Next()


What should I do?
Tags (2)
0 Kudos
4 Replies
ChrisMathers
Occasional Contributor III
Have you tried

if row.field == None or row.field2 == None:
   pass

That way if either has a None type value it would pass.
0 Kudos
TylerGarner
New Contributor
Below is the code I would use to achieve this:

cursor=arcpy.UpdateCursor("FC")
for row in cursor:
[indent]if row.field:[/indent]
[indent][indent]row.fieldoutput=row.field+row.field2
cursor.UpdateRow(row)[/INDENT][/indent]
0 Kudos
JasonScheirer
Occasional Contributor III
Try this:

row.fieldoutput=(row.field or '')+(row.field2 or '')
0 Kudos
BartłomiejStaroń
New Contributor III
I do somthing like tis and this is work

row.fieldautput = str(row.field1) + str(row.field2)


but when I am doing this empty field fill with values �??�??"None"
0 Kudos