Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. import json
  2. import csv
  3.  
  4. file_name = "AFSI"
  5. with open('nasdaq/AFSI.csv') as f:
  6. reader = csv.reader(f)
  7. your_list = list(reader)
  8.  
  9. # print your_list
  10. dict_list = []
  11. for row in your_list:
  12. d = {'id':
  13. {'date': row[0],
  14. 'sym': file_name},
  15. 'open':row[1],
  16. 'high':row[2],
  17. 'low':row[3],
  18. 'close':row[4],
  19. 'volume':row[5]}
  20. dict_list.append(d)
  21.  
  22. with open('data.json', 'w') as f:
  23. json.dump(dict_list, f)
  24. print json.dumps(dict_list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement