Created
December 2, 2015 08:54
-
-
Save aebersold/50794f9268e0603517ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sys import argv | |
import os | |
script, filename, queries, documents = argv | |
o = open("out.html", "w") | |
o.write("<html><body>") | |
with open(filename) as f: | |
content = f.readlines() | |
question = "" | |
counter = 0 | |
for line in content: | |
counter += 1 | |
cols = line.split(" ") | |
if cols[0] != question: | |
o.write("<h1>" + cols[0] + "</h1>") | |
question = cols[0] | |
p = open(os.path.join(queries, question)) | |
o.write("<h2>question:</h2><textarea style='width:100%; height:100px;'>" + p.read() + "</textarea>") | |
p.close() | |
counter = 1 | |
q = open(os.path.join(documents, cols[2])) | |
o.write("<h3>answer " + str(counter) + ":</h3><div style='width:100%'>" + q.read() + "</div>") | |
q.close() | |
o.write("</body></html>") | |
o.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment