-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathorganize_questions.py
31 lines (27 loc) · 1.05 KB
/
organize_questions.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
import pandas as pd
df = pd.read_json('SVAMP1000_modified.json')
df = df[['sQuestion', 'lEquations', 'templateType']]
f1 = open("svamp1000_Q_and_A.txt", "r")
lines_f1 = f1.readlines()
f1.close()
for i in range(24):
f2 = open("svamp1000_organized_questions/type_" + str(i) + ".txt", "w")
for index, row in df.iterrows():
if row['templateType'] == i:
temp_q = row['sQuestion']
flag = False
for line in lines_f1:
# print(line[:-1])
# print(temp_q)
if line == ("*** " + temp_q + "\n"):
flag = True
if flag and line == "~~~\n":
flag = False
f2.write("==> Solution Equation: " + row['lEquations'][0])
if len(row['lEquations']) == 2:
f2.write(" and " + row['lEquations'][1])
f2.write("\n" + line + "\n")
break
if flag:
f2.write(line)
f2.close()