I have a list of data in CSV file.
I am using loop to make them into fields… I need a code that look for a field in code that do not match this type of code “[A9]9AA9#9” Lets say “A” can be any letter and “9” can be any number. However [ ] and # symbol must be in the same location as in format.
def code():
match= 0
tree_file.readline() # skip first row
for row in tree_file:
field=row.strip()
field=field.split(",") # make Into fields
code=(field[4])
if code != "[X9]9XX9#9": #HERE SHOULD BE THE CODE
match+=1
Please can you leave some comment in code so I can understand them because I can’t understand how other solution that are available is relevant to my problem.
The regular expression you need is:
So the code can be like
Explanation
Output