我使用 python 为 ArcMap 编写了一个脚本,该脚本将获取一个包含不受支持的字符的表格,对这些适用的字段进行罗马化或音译,并创建一个带有任何可能包含在表格中的地理信息的 shapefile。我确定的其余代码工作正常。我的主要问题是能够在输入表的每一行中逐字母搜索,这是我之前工作过的,但我想我恢复到了之前的错误。
# 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.
我觉得我错过了一些东西,但不太确定。如果您需要我详细说明我的脚本中包含的其他内容,请告诉我。不一定需要为我编写脚本,但如果有一个模块或功能我可以,请告诉我它是什么以及我可以在哪里阅读它。