Guest User

Untitled

a guest
Jan 15th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. import os
  2. import csv
  3. import json
  4.  
  5. BASE_DIR = 'path/to/dataset/dir'
  6. csv_set = os.path.join(BASE_DIR, 'file.csv')
  7. json_set = os.path.join(BASE_DIR, 'file.json')
  8.  
  9. with open(csv_set, 'r') as csv_data:
  10. reader = csv.DictReader(csv_data, fields)
  11.  
  12. with open(json_set, 'w') as jsonfile:
  13. for row in reader:
  14. json.dump(row, jsonfile)
  15. jsonfile.write('\n')
Add Comment
Please, Sign In to add comment