2013-08-22 4 views
1

지원되지 않는 문자가있는 테이블을 사용하는 Python을 사용하여 ArcMap 용 스크립트를 작성하고 해당 필드를 로마자 표시 또는 음역 변환하고 모든 지리 정보가있는 shapefile을 만듭니다. 또한 테이블에 포함될 수 있습니다. 내가 결정한 나머지 코드는 올바르게 작동합니다. 내 주요 문제는 이전에 작업했던 입력 테이블의 각 행 내에서 문자로 문자로 검색 할 수있는 능력이지만 이전 오류로 되돌려 놨을 것입니다.Python을 사용하여 행 단위로 문자를 문자 단위로 검색 및 바꾸기

# Loop through each row in the copied table and replacing each cell with one based on the reference table. 
rows = access.SearchCursor(outtable, orfield) # Creates a search cursor that looks in the outtable for what is in the native language field. 
row = rows.next() # Establishes a variable that cycles row to row. 

while row: # Beginning of "while" loop. 
    for r in row: # Searches each letter within the searched row. 
     for o in orfield: # Searches each cell based on the searched field from the reference table. 
      if r == o: # If/Else statement for seeing if the letter being searched for in the intable (r) is identical to the letter in the orthography field (o). 
       r.replace(orfield, profield) # Replaces any identical letters with the associated pronunciation. 
      else: 
       row.next() # Cycles to the next row. 

나는 뭔가를 놓치고있는 것처럼 느껴진다. 내 대본에 다른 내용이 무엇인지 자세히 설명해야하는 경우 알려주십시오. 반드시 나를 위해 스크립트를 작성할 필요는 없지만, 내가 할 수있는 모듈이나 기능이 있다면, 그것이 무엇인지, 어디에서 읽을 수 있는지 알려주십시오.

답변

0

일부 세부 정보에 약간 희미하지만 코드에서 필드 데이터 개체 (생성됨/for r in row)와 일부 입력 집합의 요소를 비교하려고 시도하는 것으로 보입니다.이 문자열은 문자열을 의미합니다. Field vs string의 형식 불일치를 제외하고 Row 개체는 작성한 방식대로 반복 할 수 없다고 생각합니다. 당신은 같은과 필드를 얻을 수 있습니다 :

fldList = list() 
for fld in arcpy.ListFields(r'C:\Workspace\somedata.shp'): 
    fldList.append(fld.name) 

다음과 같은 것을 사용 fldList의 반복 :

for fld in fldList: 
    fldValue = row.getValue(fld) 
    ....do some regex/string parsing 
    ....if condition met, use row.setValue(fld, newValue) and rows.update(row)