Python - Read and plot data from a .csv

365 views Asked by At

I have a .csv full of GDP data by year for different countries. I want read the file and plot the data of only a select few of the countries in the .csv file. So far I have:

data = np.genfromtxt('The_data.csv', dtype=str, delimiter=',', names=None, usecols=np.arange(0,17))

which I think lets me read the data. How do I use matplotlib to generate a graph of GDP change over the years, but only of certain countries?

1

There are 1 answers

0
Evgeny Ivanov On
with open(The_data.csv) as f:
    content = f.readlines()
    My_list=[]
    for line in content:         
        My_list.add(line.split(';') )

or use CSV module https://docs.python.org/2/library/csv.html