앱스토어에도 보면 가계부 어플이 무척 많은데,
나는
1. 뱅크 샐러드 (초록색)
2. 간편 가계부? 편한 가계부? (빨강색)
3. 브로콜리 (파랑색)
이렇게 세 가지를 써봤다.
작년(올해 말고) 거의 한 해 동안 '간편 가계부'인가?
이름이 잘 기억이 안 나는데
빨간 돼지 저금통이 그려져 있는 가계부 어플을 제일 유용하게 잘 썼었다.
뱅크 샐러드나 브로콜리 모두 카드나 통장이 바로 연계되는 게 장점이지만
나는 학생이다보니 점심 값 같은 것을 한 명이 계산하고 카카오페이를 통해 계좌이체를 하는 경우가 많아
오히려 불편했다...
내가 긁은 경우 거액이 식비로 자동으로 분류되기도 하고, 카카오페이를 항상 기타로 두기도 애매하고...
그래서 그냥 직접 다 쓰는 간편 가계부에 정착했던 것 같다.
꽤 오래 써서 지울 때 아까웠는데 엑셀로 자동으로 백업 파일을 만들어줘서 따로 보관하고 있다.
지우게 된 이유가 분명 있었는데 기억이 잘 안 난다... 뭐였지...
어쨌든 직접 하나 하나 기록 하는 어플을 쓰다보니 가계부 작성 시간이 매우 오래 걸렸었다! 이게 이유였나??
지난 방학 동안 c++만 쓰고 python을 거의 안 써서 상기시킬겸,
또 ros의 topic을 통한 message 통신과 .launch 파일의 param 기능을 이용 하면 업데이트도 편리한 가계부가 될 것 같아
그렇게 만들어 보려고 했는데,
ros의 param 기능을 c++로만 익혀 python에서 쓰는 방식도 같이 공부해야해서 찾아볼 게 많아지니 의욕이 떨어졌다...
간편 가계부가 그리워졌다...
결론은 file/IO로 하되 .csv 파일로 하는 것도 시도해보고 이것 저것 해봤지만
.txt로 기록해두는 class 만든 게 그나마 쓸만 해서 10월 한 달 가계부로 잘 사용했다는 것이다...^^
+ 이건 다 10월 15일 이전에 있었던 일들이라 잘 기억이 안 난다는 것이다...^^
하늘 색은 다양한 버전의... 도전이 담긴 디렉토리^^ (git 사용을 배워야겠다고 느꼈다..)
빨강 색들을 이용해해서 2019.10. 가계부 기록을 했다.
1. AccountBook.py
class AccountBook:
def __init__(self, year, month):
self.year = year
self.month = month
self.food = []
self.clothesNbeauty = []
self.gift_money = []
self.transportation = []
self.daily = []
self.study = []
self.entertainment = []
self.sportsNmedical = []
self.the_others = []
self.income = []
value = []
with open("account_record.txt", "r") as f1:
l = f1.readlines()
for i in range(0, len(l)):
pos = l[i].find(":")
value.append(l[i][pos+1:])
self.food_total = int(value[0])
self.clothesNbeauty_total = int(value[1])
self.gift_money_total = int(value[2])
self.transportation_total = int(value[3])
self.daily_total = int(value[4])
self.study_total = int(value[5])
self.entertainment_total = int(value[6])
self.sportsNmedical_total = int(value[7])
self.the_others_total = int(value[8])
self.consumption_total = int(value[9])
self.income_total = int(value[10])
self.remainder = int(value[11])
def getConsumption(self):
print("\n")
print("1. food\n2. clothesNbeauty\n3. gift_money\n4. transportation\n5. daily\n6. study\n7. entertainment\n8. sportsNmedical\n9. the_others\n")
print("Please write like this.")
print("ex)\"1, egg_sundubu_zzigae, 3800\"")
print("If you finish, Write just 0(zero).\n")
for i in range(0, 50):
answer = input(": ")
if answer == 0:
break
else:
pos1 = answer.find(",")
kind = answer[0:pos1]
answer = answer[pos1+2:]
pos2 = answer.find(",")
name = answer[0:pos2]
price = answer[pos2+2:]
if kind == "1":
self.food.append([name, price])
elif kind == "2":
self.clothesNbeauty.append([name, price])
elif kind == "3":
self.gift_money.append([name, price])
elif kind == "4":
self.transportation.append([name, price])
elif kind == "5":
self.daily.append([name, price])
elif kind == "6":
self.study.append([name, price])
elif kind == "7":
self.entertainment.append([name, price])
elif kind == "8":
self.sportsNmedical.append([name, price])
elif kind == "9":
self.the_others.append([name, price])
print("\n")
def getIncome(self):
print("")
print("Please write like this.")
print("ex)\"pocket_money, 300000\"")
print("If you finish, Write just 0(zero).\n")
for i in range(0, 10):
answer = input(": ")
if answer == 0:
break
else:
pos1 = answer.find(",")
name = answer[0:pos1]
money = answer[pos1+1:]
self.income.append([name, money])
print("\n")
def calcConsumption(self):
for i in range(0, len(self.food)):
self.food_total += int(self.food[i][1])
for i in range(0, len(self.clothesNbeauty)):
self.clothesNbeauty_total += int(self.clothesNbeauty[i][1])
for i in range(0, len(self.gift_money)):
self.gift_money_total += int(self.gift_money[i][1])
for i in range(0, len(self.transportation)):
self.transportation_total += int(self.transportation[i][1])
for i in range(0, len(self.daily)):
self.daily_total += int(self.daily[i][1])
for i in range(0, len(self.study)):
self.study_total += int(self.study[i][1])
for i in range(0, len(self.entertainment)):
self.entertainment_total += int(self.entertainment[i][1])
for i in range(0, len(self.sportsNmedical)):
self.sportsNmedical_total += int(self.sportsNmedical[i][1])
for i in range(0, len(self.the_others)):
self.the_others_total += int(self.the_others[i][1])
self.consumption_total = self.food_total + self.clothesNbeauty_total + self.gift_money_total + self.transportation_total + self.daily_total + self.study_total + self.entertainment_total + self.sportsNmedical_total + self.the_others_total
print("%d.%d. food_total: %d" % (self.year, self.month, self.food_total))
print("%d.%d. clothesNbeauty_total: %d" % (self.year, self.month, self.clothesNbeauty_total))
print("%d.%d. gift_money_total: %d" % (self.year, self.month,self.gift_money_total))
print("%d.%d. transportation_total: %d" % (self.year, self.month, self.transportation_total))
print("%d.%d. daily_total: %d" % (self.year, self.month, self.daily_total))
print("%d.%d. study_total: %d" % (self.year, self.month, self.study_total))
print("%d.%d. entertainment_total: %d" % (self.year, self.month, self.entertainment_total))
print("%d.%d. sportsNmedical_total: %d" % (self.year, self.month, self.sportsNmedical_total))
print("%d.%d. the_others_total: %d" % (self.year, self.month, self.the_others_total))
print("\n%d.%d. consumption_total: %d" % (self.year, self.month, self.consumption_total))
def calcIncome(self):
for i in range(0, len(self.income)):
self.income_total += int(self.income[i][1])
print("\n%d.%d. income_total: %d" % (self.year, self.month, self.income_total))
def calcRemainder(self):
self.remainder = self.income_total - self.consumption_total
print("\n%d.%d. remainder: %d" % (self.year, self.month, self.remainder))
def record(self, date, day):
with open("account_record.txt", "w") as f1:
f1.write("%d.%d. food_total: %d" % (self.year, self.month, self.food_total))
f1.write("\n%d.%d. clothesNbeauty_total: %d" % (self.year, self.month, self.clothesNbeauty_total))
f1.write("\n%d.%d. gift_money_total: %d" % (self.year, self.month,self.gift_money_total))
f1.write("\n%d.%d. transportation_total: %d" % (self.year, self.month, self.transportation_total))
f1.write("\n%d.%d. daily_total: %d" % (self.year, self.month, self.daily_total))
f1.write("\n%d.%d. study_total: %d" % (self.year, self.month, self.study_total))
f1.write("\n%d.%d. entertainment_total: %d" % (self.year, self.month, self.entertainment_total))
f1.write("\n%d.%d. sportsNmedical_total: %d" % (self.year, self.month, self.sportsNmedical_total))
f1.write("\n%d.%d. the_others_total: %d" % (self.year, self.month, self.the_others_total))
f1.write("\n%d.%d. consumption_total: %d" % (self.year, self.month, self.consumption_total))
f1.write("\n%d.%d. income_total: %d" % (self.year, self.month, self.income_total))
f1.write("\n%d.%d. remainder: %d" % (self.year, self.month, self.remainder))
with open("contents_record.txt", "a") as f2:
f2.write("\n%d.%d.%d.%s.\n" % (self.year, self.month, date, day))
f2.write("\nfood\n")
for i in range(0, len(self.food)):
f2.write(": " + self.food[i][0] + " " + self.food[i][1] + "\n")
f2.write("\nclothesNbeauty\n")
for i in range(0, len(self.clothesNbeauty)):
f2.write(": " + self.clothesNbeauty[i][0] + " " + self.clothesNbeauty[i][1] + "\n")
f2.write("\ngift_money\n")
for i in range(0, len(self.gift_money)):
f2.write(": " + self.gift_money[i][0] + " " + self.gift_money[i][1] + "\n")
f2.write("\ntransportation\n")
for i in range(0, len(self.transportation)):
f2.write(": " + self.transportation[i][0] + " " + self.transportation[i][1] + "\n")
f2.write("\ndaily\n")
for i in range(0, len(self.daily)):
f2.write(": " + self.daily[i][0] + " " + self.daily[i][1] + "\n")
f2.write("\nstudy\n")
for i in range(0, len(self.study)):
f2.write(": " + self.study[i][0] + " " + self.study[i][1] + "\n")
f2.write("\nentertainment\n")
for i in range(0, len(self.entertainment)):
f2.write(": " + self.entertainment[i][0] + " " + self.entertainment[i][1] + "\n")
f2.write("\nsportsNmedical\n")
for i in range(0, len(self.sportsNmedical)):
f2.write(": " + self.sportsNmedical[i][0] + " " + self.sportsNmedical[i][1] + "\n")
f2.write("\nthe_others\n")
for i in range(0, len(self.the_others)):
f2.write(": " + self.the_others[i][0] + " " + self.the_others[i][1] + "\n")
f2.write("\nincome\n")
for i in range(0, len(self.income)):
f2.write(": " + self.income[i][0] + " " + self.income[i][1] + "\n")
2. main.py
import AccountBook
cottonzero = AccountBook.AccountBook(2019, 11)
cottonzero.getConsumption()
cottonzero.getIncome()
cottonzero.calcConsumption()
cottonzero.calcIncome()
cottonzero.calcRemainder()
cottonzero.record(1, "FRI")
contents_record.txt에는 쭉 이어서 하루 하루가 기록되어 있고
account_record_2019_10.txt에는 매일 업데이트되어 10월 최종 결산이 된 수치가 적혀있다.
매월 1일에 account_record.txt에서 각 항목 값을 모두 0으로 적어두고 사용... 하는 방식이다.
ros 버전도 rosrun으로 실행은 되지만 launch에 param으로 기록 누적 시키기를 못 해서...
혹시 나중에 완성하면 그때 올려야지.
11월 가계부는 엑셀로 적는 걸로^^* 엑셀 공부해야지!
저기 보면 10월 총 소비가 848,965원인데 적금 40만 원을 빼도 448,965원이다...
과 돕바도 사고 그래서 돈을 좀 많이 썼다.
11월엔 버는 돈도 없을 텐데 소비 줄이자~~~
'IT' 카테고리의 다른 글
[c언어 기초] 조건문 switch 공부 (0) | 2019.12.01 |
---|---|
[marketing] 마케팅 기초 - 책 '공모전 무작정 따라하기' (0) | 2019.11.20 |
[git/github] 책 '만들면서 배우는 Git+GitHub 입문'으로 공부 (0) | 2019.11.09 |
댓글