Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
907 B
1
Indexable
Never
import json
from datetime import date

fileLocation = "LogData.json"

def loadData():
    fileData ={}
    with open(fileLocation,"r") as fileDataObject:
        fileData = json.load(fileDataObject)
    return fileData

def saveData(data):
    with open(fileLocation, "w") as fileDataObject:
        json.dump(data, fileDataObject)

def resetData():
    saveData({})

def createLog(logData):
    today = str(date.today())
    logData[today] = getLog(4)
    print("Created a new log : ")
    print(json.dumps(logData[today],indent=1))
    return loadData

def getLog(n):
    log = {}
    for i in range(0,n):
        log["Activity " + str(i+1)] = input("Enter activity " + str(i+1) + " : ")
    return log

def displayLog(logData):
    print(json.dumps(logData,indent=1))
    
def main():
    #resetData()
    logData = loadData()
    createLog(logData)
    saveData(logData)
    #displayLog(logData)

main()