-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfda_simple.py
More file actions
26 lines (22 loc) · 809 Bytes
/
fda_simple.py
File metadata and controls
26 lines (22 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import csv
import logging
import json
from utils import write_first
def from_json():
count = 0
with open('device-510k-0001-of-0001.json', encoding='utf-8') as inputfile:
file = json.load(inputfile)
apps = file['results']
for app in apps:
if 'registration_number' in app['openfda']:
app['openfda'].pop('registration_number')
if 'fei_number' in app['openfda']:
app['openfda'].pop('fei_number')
# unpack
for field in app['openfda']:
app[field + 'open_fda_field'] = app['openfda'][field]
app.pop('openfda')
write_first(apps)
if __name__ == '__main__':
logging.basicConfig(format='%(asctime)s %(levelname)s:%(message)s', level=logging.DEBUG)
from_json()