-
Notifications
You must be signed in to change notification settings - Fork 42
/
rulesFromTemplate.py
40 lines (28 loc) · 995 Bytes
/
rulesFromTemplate.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
__author__ = 'RahulRRixe'
from sys import argv
T = "Blah blah blah COMPID, blah blhah COMPID, COMPNAME"
C = [
["B1", "Boogie1"],
["B2", "Boogie2"],
["B3", "Boogie3"],
["B4", "Boogie4"],
]
S = "CNBC"
if __name__ == "__main__":
print len(argv)
if len(argv) != 4:
print 'usage: python '+argv[0]+' <template_file_path> <companies_list_path>'
else:
print 'Starting Process'
template_file = argv[1]
companies_list = argv[2]
source_name = argv[3]
template = open(template_file, 'r').read()
companies = map(lambda x: x.strip().split(";"), open(companies_list, 'r').readlines())
for (ind, c) in enumerate(companies):
fout = open("sources/%s%d.json"%(source_name, ind+1), 'w')
print 'Writing to', fout.name
content = template.replace("COMPID", c[1])
fout.write(content.replace("COMPNAME", c[0]))
fout.close()
print 'Process complete'