forked from galaxyproject/tiaas2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
import.py
64 lines (54 loc) · 1.39 KB
/
import.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
import dateparser
from training.models import Training
headers = (
"received",
"email",
"title",
"description",
"start",
"end",
"location",
"use_gtn",
"attendance",
"advertise",
"blogpost",
"website",
"gtn_links",
"training_identifier",
"name",
"non_gtn_links",
"other_requests",
"processed",
)
x = open("data.tsv", "r").read().strip().split("\n")
for idx, line in enumerate(x):
if idx == 0:
continue
line = line.split("\t")
line = line[0 : len(headers)]
d = dict(zip(headers, line))
# del d['days_until']
# del d['gdpr']
# del d['days_since']
del d["blogpost"]
d["received"] = dateparser.parse(d["received"]).date()
d["start"] = dateparser.parse(d["start"]).date()
d["end"] = dateparser.parse(d["end"]).date()
if d["processed"].lower().startswith("y"):
d["processed"] = "AP"
else:
d["processed"] = "UN"
if d["advertise"].lower().startswith("y"):
d["advertise"] = "Y"
else:
d["advertise"] = "N"
if d["use_gtn"].lower().startswith("y"):
d["use_gtn"] = "Y"
else:
d["use_gtn"] = "N"
d["training_identifier"] = d["training_identifier"][0:20]
d["location"] = [x.strip().split(" ")[0] for x in d["location"].split(",")]
__import__("pprint").pprint(d)
t = Training(**d)
t.save()