initial
This commit is contained in:
commit
c180d4f7ab
27
data.csv
Normal file
27
data.csv
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
Category,Amount,Description
|
||||||
|
Travel,1000,Cab from jindal to blr airport
|
||||||
|
Travel,29306,Flights
|
||||||
|
Accomodation,18250,Hotel stay
|
||||||
|
Travel,1500,Cab to laxmi empire
|
||||||
|
Travel,250,Cab to restaurent lunch
|
||||||
|
Food,730,Lunch
|
||||||
|
Travel,300,Auto to kayak
|
||||||
|
Fun,4200,Kayak
|
||||||
|
Travel,250,Cab to hotel
|
||||||
|
Food,210,Snacks
|
||||||
|
Travel,250,Cab to farmhouse
|
||||||
|
Food,1580,Farmhouse dinner
|
||||||
|
Travel,350,Auto to hotel
|
||||||
|
Travel,250,Hotel to Benaulim
|
||||||
|
Travel,250,Benaulim to hotel
|
||||||
|
Food,803,Lunch at hotel
|
||||||
|
Travel,600,Hotel to cavelossim
|
||||||
|
Food,680,Evening snacks at shack
|
||||||
|
Food,1280,Dinner at shack
|
||||||
|
Travel,800,cavelossim to hotel
|
||||||
|
Other,100,Cab cancellation
|
||||||
|
Travel,250,Cab to benaulim
|
||||||
|
Food,1510,Lunch at beach
|
||||||
|
Travel,743,Cab to airport
|
||||||
|
Food,125,Water bottle
|
||||||
|
Travel,1422,Cab to Jindal
|
||||||
|
40
main.py
Normal file
40
main.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import csv
|
||||||
|
|
||||||
|
data_csv = 'data.csv'
|
||||||
|
|
||||||
|
all_categories = dict()
|
||||||
|
with open ('data.csv', mode='r') as csv_file:
|
||||||
|
csv_reader = csv.DictReader(csv_file)
|
||||||
|
line_count = 0
|
||||||
|
for row in csv_reader:
|
||||||
|
if line_count == 0:
|
||||||
|
line_count += 1
|
||||||
|
category = row['Category']
|
||||||
|
amount = row['Amount']
|
||||||
|
if category not in all_categories:
|
||||||
|
all_categories[category] = int(amount);
|
||||||
|
else:
|
||||||
|
all_categories[category] += int(amount);
|
||||||
|
|
||||||
|
description = row['Description']
|
||||||
|
line_count += 1
|
||||||
|
|
||||||
|
print(all_categories)
|
||||||
|
|
||||||
|
def func(pct, allvals):
|
||||||
|
absolute = int(pct/100.*sum(allvals.values()))
|
||||||
|
return "{:.1f}%\n(Rs {:d})".format(pct, absolute)
|
||||||
|
|
||||||
|
labels = all_categories.keys()
|
||||||
|
sizes = all_categories.values()
|
||||||
|
|
||||||
|
fig, ax = plt.subplots()
|
||||||
|
ax.pie(sizes, autopct=lambda pct: func(pct, all_categories), textprops=dict(color="w")),
|
||||||
|
|
||||||
|
total = sum(all_categories.values())
|
||||||
|
ax.legend(all_categories.keys(), loc="center left", bbox_to_anchor=(1, 0, 0.5, 1), title="Total: Rs {:d}".format(total))
|
||||||
|
|
||||||
|
ax.set_title("Goa Trip Expenses")
|
||||||
|
|
||||||
|
plt.show()
|
||||||
Loading…
x
Reference in New Issue
Block a user