Created
March 23, 2021 23:21
-
-
Save KickedDroid/23075f68c10fd5c548cb22c845ad0f63 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
import numpy as np | |
from pathlib import Path | |
import csv | |
csvPath = Path("budget_data.csv") | |
# Get the total amount of profit/loss | |
total = 0 | |
average = 0 | |
minimum = 0 | |
maximum = 0 | |
totalMonths = 0 | |
minDate = '' | |
maxDate = '' | |
with open(csvPath, 'r') as csvfile: | |
csvreader = csv.reader(csvfile, delimiter=',') | |
header = next(csvreader) | |
for row in csvreader: | |
total += int(row[1]) | |
totalMonths +=1 | |
if minimum == 0: | |
minimum = int(row[1]) | |
minDate = str(row[0]) | |
elif int(row[1]) < minimum: | |
minimum = int(row[1]) | |
minDate = str(row[0]) | |
elif maximum == 0: | |
maximum = int(row[1]) | |
maxDate = str(row[0]) | |
elif int(row[1]) > maximum: | |
maximum = int(row[1]) | |
maxDate = str(row[0]) | |
average = total / totalMonths | |
print("Total Months: " + str(totalMonths) ) | |
print('Total: $'+ str(total)) | |
print('Average Change: $'+ str(average)) | |
print('Greatest Increase in Profits: '+ maxDate +' '+ str(maximum)) | |
print('Greatest Decrease in Profits: '+ minDate +' '+ str(minimum)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment