I am trying to create a barchart showing off the price of spotify premium from different countries around europe. I do not know how to import a csv file to create this graph. this is my current code
import pygal as pg
import csv
filename = 'premiumusersEurope.csv'
with open(filename) as f:
reader = csv.reader(f)
#print(list(reader))
pg_bar = pg.Bar()
for row in reader:
x.append(int(row[0]))
y.append(int(row[1]))
pg_bar.render_to_file("simple.svg")
This code is not working, and i cannot find out why.
This is my data any help will be appriciated
Hope this may help:
with open(filename, mode='r') as f:
or
with open(filename, 'r') as f:
or
with open(filename, 'rb') as f:
or please refer this link: https://realpython.com/python-csv/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.