Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- def revenuecompare():
- revenue2014 = 0.0
- revenue2015 = 0.0
- revenue2016 = 0.0
- path = r'D:\Python\Databases\EMC_data.csv'
- with open(path) as csvfile:
- database_reader = csv.reader(csvfile, delimiter = ' ',lineterminator= " ")
- for row in range(database_reader.rowcount):
- quantity = row[2]
- quantity = quantity.replace(" ","")
- price = row[3]
- price = price[1:].replace(" ","")
- if quantity.isalpha() or price.isalpha():
- continue
- elif "2014" in row[1]:
- revenue2014 += float(quantity)*float(price)
- elif "2015" in row[1]:
- revenue2015 += float(quantity)*float(price)
- elif "2016" in row[1]:
- revenue2016 += float(quantity)*float(price)
- else:
- continue
- print("2014 annual revenue was: ",revenue2014)
- print("2014 annual revenue was: ",revenue2015)
- print("2014 annual revenue was: ",revenue2016)
- #Take Yearly revenues and put them in a list
- #turn the list into a bar graph
- revenuecompare()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement