cash4web/writer.py

29 lines
856 B
Python
Raw Permalink Normal View History

#!/usr/bin/env python3
import csv
import static
def writeFile(row, filename = "list.csv", fieldnames = static.fieldlist):
with open(filename, "a") as csf:
return csv.DictWriter(csf, fieldnames).writerow(row)
def inputQuery():
output = {}
output["number"] = input("Credit Card Number: ")
assert output["number"].isdecimal() and len(output["number"]) == 16, "Credit card number must be a 16-digit decimal number"
output["validity"] = input("Validity Date: ")
output["cvc"] = input("CVC2: ")
output["ccn"] = input("Customer Control Number: ")
assert output["ccn"].isdecimal() and len(output["ccn"]) == 6, "Customer Control Number must be a 6-digit decimal number"
output["purchased_on"] = input("Date of purchase: ")
output["purchased_at"] = input("Place of purchase: ")
return output
if __name__ == "__main__":
writeFile(inputQuery())