Repository navigation
Expand file tree
/
Copy pathFinance Report.py
More file actions
123 lines (92 loc) · 3.39 KB
/
Copy pathFinance Report.py
File metadata and controls
123 lines (92 loc) · 3.39 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import csv
import os
#A debit is an accounting entry that either increases an asset or expense account (checking),
#or decreases a liability or equity account (credit card)
#A credit is an accounting entry that either increases a liability or equity account (credit card),
#or decreases an asset or expense account (checking).
bankPath = "./Banks"
slash = "./"
class Date:
def __init__(self, date):
self.month = 1
self.day = 1
self.year = 2000
self.stringValue = date
self.Parse()
def Parse(self):
values = self.stringValue.split("/")
self.month = values[0]
self.day = values[1]
self.year = values [2]
def Print(self):
print("Date: " + self.stringValue)
class Transaction:
def __init__(self, dt, amnt, typ, dec, td):
self.date = Date(dt)
self.amount = amnt
self.type = typ
self.desc = dec
self.typeDetails = td
def Print(self):
print("Transaction: ")
self.date.Print()
print(self.amount)
print("Type: " + self.type)
print("Description: " + self.desc)
class Account:
def __init__(self, typ):
self.type = typ
self.transactions = []
class Bank:
def __init__(self, n):
self.name = n
self.files = []
self.accounts = []
def ParseForInput(self):
if self.name == "Chase":
self.ParseChase()
elif self.name == "Citi":
self.ParseCiti()
def ParseChase(self):
for file in self.files:
with open(bankPath+slash+self.name+ slash + file, mode='r') as csv_file:
csv_reader = csv.reader(csv_file)
line_count = 0
for row in csv_reader:
if line_count != 0:
self.transactions.append(Transaction(row[1], row[3], row[0], row[2], row[4]))
line_count += 1
def ParseCiti(self):
for file in self.files:
with open(bankPath+slash+self.name+ slash + file, mode='r') as csv_file:
csv_reader = csv.reader(csv_file)
line_count = 0
for row in csv_reader:
if line_count != 0:
amount = 0
typ = "NOT SET"
if row[3] != "":
amount == row[3]
typ = "DEBIT"
elif row[3] == "" and row[4] != "":
amount = row[4]
typ = "CREDIT"
self.transactions.append(Transaction(row[1], row[3], row[0], row[2], "n/a"))
line_count += 1
def PrintTransactions(self):
for t in self.transactions:
t.Print()
print(" ")
def main():
print("Collecting data!")
banks = os.listdir(bankPath )
bankList = []
for bank in banks:
tmp = Bank(bank)
tmp.files = os.listdir(bankPath + "/" + bank)
bankList.append(tmp)
for bank in bankList:
if bank.name == "Citi":
bank.ParseForInput()
#bank.PrintTransactions()
main()