I have an rfid reader which when scanned returns a UID as "backData"
I have my users (username and UID) stored in a text file.
I've managed to read the text file into a python dictionary, but when i scan my card, it is only accepting the last UID in the text file.
Text File:
164 168 124 90 42, user1
114 156 203 196 225, user2
Python Code:
for line in uid_file:
info = line.split(",")
key = info[0]
uname = info[1]
c = len(uname)-1
uname = uname[0:c]
uid_dict[key] = uname
USER = [int(i) for i in key.split()]
if backData == USER:
f = open("/mnt/lock_logs/lock_log.csv", "a");
print f
value = ('\n') + uname
myString = str(value)
f.write(myString)
f.close()
else:
print "Access Denied"
So if I scan the card assigned to user2, it works, but if I scan the card assigned to user1, I get Access Denied.
If i print the variable USER, it returns both UIDs from the text file. Any ideas on what I need to change??