Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import csv
- import json
- BASE_DIR = 'path/to/dataset/dir'
- csv_set = os.path.join(BASE_DIR, 'file.csv')
- json_set = os.path.join(BASE_DIR, 'file.json')
- with open(csv_set, 'r') as csv_data:
- reader = csv.DictReader(csv_data, fields)
- with open(json_set, 'w') as jsonfile:
- for row in reader:
- json.dump(row, jsonfile)
- jsonfile.write('\n')
Add Comment
Please, Sign In to add comment