-
Notifications
You must be signed in to change notification settings - Fork 3
/
she-process.py
executable file
·91 lines (70 loc) · 2.25 KB
/
she-process.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env python
# coding: utf-8
# In[1]:
# pip install pandas openpyxl jinja2 faker
import pandas as pd
import pathlib
from jinja2 import Template
from faker import Faker
import sys
# In[2]:
df_names = pd.read_csv('out.csv')
# print(df_names[:4])
names = df_names['en'].sample(n=1, random_state=1)
# print(names.values)
# print(names.values[0])
# In[3]:
# goal: nested lists of form: [index, suffix, birthDate, centre...]
# for now, suffix = name and suffix
fake = Faker()
def genfsh(lang, obs):
for i in range(obs):
tempname = df_names[lang].sample(n=1)
tempname = tempname.values[0]
suffix = lang + str(i)
name = tempname + str(i)
if lang == 'en':
orgname = "Government Hospital"
centre = 'Vaccination Site'
if lang == 'es':
orgname = "Hospital del Gobierno"
centre = "Sitio de vacunación"
if lang == 'fr':
orgname = "Hôpital du gouvernement"
centre = "Site de vaccination"
if lang == 'ar':
orgname = "مستشفى حكومي"
centre = "موقع التطعيم"
if lang == 'zh':
orgname = "政府医院"
centre = "疫苗接种现场"
if lang == 'ru':
orgname = "Государственная больница"
centre = "Сайт вакцинации"
x = fake.date_between(start_date='-80y', end_date='-15y')
birthDate = str(x)
identifier = lang + str(9999) + str(i)
# this prints oddly bc of the mix of rtl-ltr langs?
print(lang, suffix, name, birthDate, identifier)
# put through jinja2
path = pathlib.Path('she-template.fsh')
text = path.read_text()
t = Template(text)
msg = t.render(
suffix=suffix,
name=name,
birthDate=birthDate,
identifier=identifier,
orgname=orgname,
centre=centre
)
path_out = pathlib.Path(f"input/fsh/{suffix}.fsh")
path_out.write_text(msg)
# In[4]:
print("command:", str(sys.argv))
langs = ['en', 'es', 'fr', 'ar', 'zh', 'ru']
if sys.argv[1] in langs:
genfsh(str(sys.argv[1]), int(sys.argv[2]))
else:
genfsh('ar', 100)
# In[ ]: