-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPyBank_starter.py
More file actions
57 lines (31 loc) · 1.18 KB
/
PyBank_starter.py
File metadata and controls
57 lines (31 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# -*- coding: UTF-8 -*-
"""PyBank Homework Starter File."""
# Dependencies
import csv
import os
# Files to load and output (update with correct file paths)
file_to_load = os.path.join("Resources", "budget_data.csv") # Input file path
file_to_output = os.path.join("analysis", "budget_analysis.txt") # Output file path
# Define variables to track the financial data
total_months = 0
total_net = 0
# Add more variables to track other necessary financial data
# Open and read the csv
with open(file_to_load) as financial_data:
reader = csv.reader(financial_data)
# Skip the header row
header = next(reader)
# Extract first row to avoid appending to net_change_list
# Track the total and net change
# Process each row of data
for row in reader:
# Track the total
# Track the net change
# Calculate the greatest increase in profits (month and amount)
# Calculate the greatest decrease in losses (month and amount)
# Calculate the average net change across the months
# Generate the output summary
# Print the output
# Write the results to a text file
with open(file_to_output, "w") as txt_file:
txt_file.write(output)