# Arup Guha
# 4/10/2020
# Program to read cumulative data about Covid-19 cases in US
# output day by day new case numbers to a file.

# Number of days in each month in 2020. Index 0 is not used.
DAYSINMONTHS = [0,31,29,31,30,31,30,31,31,30,31,30,31]

inputFile = open("covid19cumulative.txt", "r")

# Store tokens from first line in a list.
toks = inputFile.readline().split()

# Get starting date for file.
month = int(toks[0])
day = int(toks[1])
year = int(toks[2])

# Open output file, make table header.
outputFile = open("covid19daybyday.txt", "w")
outputFile.write("Date\t\tNew Cases\n")
outputFile.write("----\t\t---------\n")

# This is all of the data as strings.
alldataStr = inputFile.readline().split()

# Just convert data to ints.
alldata = []
for i in range(len(alldataStr)):
    alldata.append(int(alldataStr[i]))

for i in range(len(alldata)):

    # First row is special, no subtraction.
    if i == 0:
        outputFile.write(str(month)+"/"+str(day)+"/"+str(year)+"\t"+str(alldata[0])+"\n")

    else:
        outputFile.write(str(month)+"/"+str(day)+"/"+str(year)+"\t"+str(alldata[i]-alldata[i-1])+"\n")

    # Go to the next day (only works within 2020).

    # We advance to the next month.
    if DAYSINMONTHS[month] == day:
        month += 1
        day = 1

    # Just go to the next day.
    else:
        day += 1

# Close both files.
inputFile.close()
outputFile.close()
