This commit is contained in:
cool-mist 2025-08-23 10:49:04 +05:30
commit c180d4f7ab
2 changed files with 67 additions and 0 deletions

27
data.csv Normal file
View 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
1 Category Amount Description
2 Travel 1000 Cab from jindal to blr airport
3 Travel 29306 Flights
4 Accomodation 18250 Hotel stay
5 Travel 1500 Cab to laxmi empire
6 Travel 250 Cab to restaurent lunch
7 Food 730 Lunch
8 Travel 300 Auto to kayak
9 Fun 4200 Kayak
10 Travel 250 Cab to hotel
11 Food 210 Snacks
12 Travel 250 Cab to farmhouse
13 Food 1580 Farmhouse dinner
14 Travel 350 Auto to hotel
15 Travel 250 Hotel to Benaulim
16 Travel 250 Benaulim to hotel
17 Food 803 Lunch at hotel
18 Travel 600 Hotel to cavelossim
19 Food 680 Evening snacks at shack
20 Food 1280 Dinner at shack
21 Travel 800 cavelossim to hotel
22 Other 100 Cab cancellation
23 Travel 250 Cab to benaulim
24 Food 1510 Lunch at beach
25 Travel 743 Cab to airport
26 Food 125 Water bottle
27 Travel 1422 Cab to Jindal

40
main.py Normal file
View 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()