-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
40 lines (30 loc) · 1.03 KB
/
test.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import json
from medify.models import *
import os
data_file = open(os.path.join("data", "medicinal.json"))
data = json.load(data_file)
ls= data["data"]
for item in ls:
item["approval_date"] = item["approval_date"][-4:]+"-"+item["approval_date"][3:5]+"-"+item["approval_date"][:2]
med= ApprovedMedication(**item)
med.save()
data_file = open(os.path.join('data', 'illegal.json'))
data = json.load(data_file)
ls= data["data"]
for item in ls:
med= IllegalMedication(**item)
med.save()
data_file = open(os.path.join('data', 'pharmacies.json'))
data = json.load(data_file)
ls= data["data"]
for item in ls:
pharmacy= Pharmacy(**item)
pharmacy.save()
data_file = open(os.path.join('data', 'devices.json'))
data = json.load(data_file)
ls= data["data"]
for item in ls:
item["registration_date"] = item["registration_date"][-4:]+"-"+item["registration_date"][3:5]+"-"+item["registration_date"][:2]
item["expiry_date"] = item["expiry_date"][-4:]+"-"+item["expiry_date"][3:5]+"-"+item["expiry_date"][:2]
dev= ApprovedDevice(**item)
dev.save()