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.
我覺得我錯過了一些東西,但不太確定。如果您需要我詳細說明腳本中包含的內容,請告訴我。不一定需要爲我編寫腳本,但如果有一個模塊或功能,我可以讓你知道它是什麼以及我可以在哪裏讀到它。