There is file with logs get list of ding ids that appear in this file

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#There is a file with logs, get list of ding ids that appear in this file and write to txt file,
#get list mac,ding_id and write into csv file
import json, csv
with open('delete_many_one_05_08_2019.csv', 'r') as csv_file, open('output.csv', 'w') as save_file:
file = csv.DictReader(csv_file)
jason = [x['json'].replace('""', '"') for x in file]
for x in jason:
data = json.loads(x)
device_id = data['device_id']
ding_id = data['ding_id']
save_file.write(f'{device_id},{ding_id}\n')