2017-01-04 23 views
0

同じエラー結果でポストを調査しましたが、カーソルがテーブル内のヌル値に達して分割を実行しようとしていると思います。私は、条件付きステートメントを使用して、プログラムが実行され続けて、None値になっても同じエラーが発生した場合は、試してみました。ここに私のコードは次のとおりです。AttributeError: 'NoneType'オブジェクトにカーソルの属性 'split'がありません

f1 = "Address" 

f2 = "Cust1stStWord" 

f3 = "ST_NM_BASE" 

f4 = "Street1stStWord" 

print "Running cursors" 
with arcpy.da.UpdateCursor("gimLyrJoin",[f1, f2, f3, f4]) as cursor: 
    for row in cursor: 
     if row[2] != None: 
      continue 
     # first update fields with street names that have directional prefixes 
     if len(row[0].split(" ")[1]) == 1 and row[0].split(" ")[2] != "ST": 
      row[1] = row[0].split(" ")[2][0:3] 
      row[3] = row[2].split(" ")[2][0:3] 
     # now look for street names that start with SAINT in customer records and change them to ST 
     elif row[0].split(" ")[1] == "SAINT": 
      row[1] = "ST " 
      row[3] = row[2].split(" ")[1][0:3] 
     #Change remaining records to first three letters of street name 
     else: 
      row[1] = row[0].split(" ")[1][0:3] 
      row[3] = row[2].split(" ")[1][0:3] 
     cursor.UpdateRow(row) 

そして、ここではエラーです:

Traceback (most recent call last): 
    File "N:\Python\Completed scripts\GIM_Street_Updates.py", line 78, in <module> 
    row[3] = row[2].split(" ")[1][0:3] 
AttributeError: 'NoneType' object has no attribute 'split' 
+1

split()でエラーが発生するのは、どの行ですか?エラーが発生した場合、次のエラーメッセージが表示されます。 –

+0

肯定的ではありませんが、最初の行が分割されていることは間違いありません。ポストで完全なトレースバックを提供します。 – ShaunO

+0

ここにはどこに情報がありますか? split()ですべての行の前にデバッグメッセージを追加してみてください。 –

答えて

0

私は行が[2] ==なし」に値を変更していない場所の条件が見つけるために作られたループの開始時に、

with arcpy.da.UpdateCursor("gimLyrJoin",[f1, f2, f3, f4]) as cursor: 
     for row in cursor: 
      # fix null values 
      if row[2] == None: 
       row[2] = " " 
       cursor.updateRow(row) 
       continue 
      elif len(row[0].split(" ")[1]) == 1 and row[0].split(" ")[2] != "ST": 
       row[1] = row[0].split(" ")[2][0:3] 
       # ST_NM_BASE seems to not include prefix so okay to 0 index 
       row[3] = row[2].split(" ")[0][0:3] 
      # now look for street names that start with SAINT in customer records and change them to ST 
      elif row[0].split(" ")[1] == "SAINT": 
       row[1] = "ST " 
       row[3] = row[2].split(" ")[0][0:3] 
      #Change remaining records to first three letters of street name 
      else: 
       row[1] = row[0].split(" ")[1][0:3] 
       row[3] = row[2].split(" ")[0][0:3] 
      cursor.updateRow(row) 
関連する問題