SHARE
TWEET

Untitled

a guest Oct 14th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top