Skip to content

Instantly share code, notes, and snippets.

@ollytheninja
Last active December 29, 2018 03:00
Show Gist options
  • Save ollytheninja/5a45099f737f1926c93bd6c52744cee9 to your computer and use it in GitHub Desktop.
Save ollytheninja/5a45099f737f1926c93bd6c52744cee9 to your computer and use it in GitHub Desktop.
Pairs RFID cards with their barcodes
import os
output_file = "card_pairs.csv"
magic_number = 6
if output_file not in os.listdir('.'):
with open(output_file, "w") as f:
f.write("id_number,card_serial\n")
def do_the_thing():
a = input("scan card: ")
b = input("waiting for second input: ")
if len(a) > magic_number:
card_serial = a
id_number = b
else:
card_serial = b
id_number = a
if a == b:
print("##########")
print("Error, same number twice!")
print("##########\n")
return
print("ID: {}\nSerial: {}".format(id_number, card_serial))
with open(output_file, "a") as f:
f.write("{},{}\n".format(id_number,card_serial))
print("\n\n")
while 1:
do_the_thing()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment