Created
November 21, 2018 21:47
-
-
Save Tokugero/098436dd38aa2282bc4c1abccdebcf0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! bin/python | |
import json | |
from datetime import datetime,date | |
#open report to memory (look for date today) | |
filename = str(date.today())+".json" | |
dbRaw = open("db/"+filename, "r") | |
dbLines = dbRaw.readlines() | |
try: | |
db = json.loads(dbLines[0]) | |
except: | |
db = [] | |
dbRaw.close() | |
#ask for raw_input new information | |
newInfo = [] | |
name = "" | |
sTime = "" | |
eTime = "" | |
location = "" | |
print "Welcome to the jungle, where we have fun and play games. Input some information to track: \n" | |
while True: | |
name = raw_input("Name: ") | |
sTime = raw_input("Start time: ") | |
eTime = raw_input("End time: ") | |
location = raw_input("Location: ") | |
contQ = raw_input("Would you like to continue? (y/n): ") | |
newInfo.append({"name":name, | |
"start":sTime, | |
"end":eTime, | |
"location":location, | |
"entered":str(date.today())}) | |
if "y" in contQ.lower(): | |
continue | |
else: | |
break | |
#add new row to db table | |
for row in newInfo: | |
db.append(row) | |
#print total table | |
print "Entry Date\tName\tLocation\tStart Time\tEnd Time \t" | |
for row in db: | |
print row["entered"]+"\t"+row["name"]+"\t"+row["location"]+"\t"+row["start"]+"\t"+row["end"]+"\t" | |
#write to file db | |
dbRaw = open("db/"+filename, "w+") | |
dbStore = json.dumps(db) | |
dbRaw.write(dbStore) | |
dbRaw.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment