I have a file with 600k+ records of string labels I am trying to edit with an update cursor using both the string modules and fnmatch to find patterns to edit. The section using fnmatch is successfully printing the matched records but not changing / parsing out the matched pattern.
There is no error and there is no change to the record. What am I missing with my syntax?
(Also - side issue, the last print row 4 statement only prints the first record of the file.)
The result samples are unchanged from original text
1000STR92SE
8000STR37NW
7000STR35SW
8000STR44
1000STR88SE
1000STR74SE
But results need to be
92SE
37NW
35SW
44
88SE
74SE
def newlabel():
#Global Conversions - works on editing the string
with arcpy.da.UpdateCursor(mvum_fc, newfields) as uc:
for row in uc:
if row[1] == None or row[1].startswith('0'):
row[4] = '{}'.format(row[4].lstrip(ascii_letters).replace('_', "-").lstrip('0').replace(' ', '-'))
if row[1] == None or row[1].startswith('-'):
row[4] = '{}'.format(row[4].lstrip('-').lstrip('0'))
#Regional Conversions - lstrip and replace tried - not changing text.
elif row[1].startswith('0118'):
pattern = ('?000STR*')
match = fnmatch.fnmatch(row[4], pattern)
if match == True:
row[4] = '{}'.format(row[4].lstrip('?000STR'))
print(row[4])
uc.updateRow(row)
print(row[4])
question from:
https://stackoverflow.com/questions/65923683/python-2-7-fnmatch-not-editing-text 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…