Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1.  import csv
  2. import numpy
  3. def load_to_dict(filename):                                                                      
  4.     dictionary = {}
  5.     with open(filename,"r") as file:
  6.         x = csv.reader(file,delimiter=',')
  7.         for row in x:
  8.             array = []
  9.             for i in range(1,len(row)):
  10.                 array.append(int(row[i]))
  11.  
  12.            if row[0] == 'country':
  13.                 dictionary.__setitem__('Time',numpy.array(array))
  14.             else:
  15.                 dictionary.__setitem__(row[0],numpy.array(array))
  16.     return dictionary
  17. i = load_to_dict("income_per_person.csv")
  18. print(i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement