Thanks, very simple but I missed that because it was supposed be in HTML code!
On Tue, May 10, 2011 at 1:16 PM, Spyros Charonis <s.charo...@gmail.com>wrote: > Hello everyone, > > I have a Python script that extracts some text from a database file and > annotates another file, > writing the results to a new file. Because the files I am annotating are > ASCII, > I am very restricted as to how I can annotate the text, and I would like to > instead > write the results to HTML so that I can annotate my file in more visually > effective ways,e.g. by changing text color > where appropriate. My program extracts text from a database, reads a file > that is to be annotated, and writes those > annotations to a newly created (.htm) file > I include the following headers at the beginning of my program: > > print "Content-type:text/html\r\n\r\n" > print '<html>' > print '<body>' > > The part of the program that finds the entry I want and produces the > annotation is about > 80 lines down and goes as follow: > > file_rmode = open('/myfolder/alignfiles/query1, 'r') > file_amode = open('/myfolder/alignfiles/query2, 'a+') > > file1 = motif_file.readlines() # file has been created in code not shown > file2 = file_rmode.readlines() > > for line in seqalign: > for item in finalmotifs: > item = item.strip().upper() > if item in line: > newline = line.replace(item, "<p> <font color = "red"> item > </font> </p>") # compiler complains here about the word "red" > # sys.stdout.write(newline) > align_file_amode.write(line) > > print '</body>' > print '</html>' > > motif_file.close() > align_file_rmode.close() > align_file_amode.close() > > The Python compiler complains on the line I try to change the font color, > saying "invalid syntax". Perhaps I > need to import the cgi module to make this a full CGI program? (I have > configured my Apache server). Or alternatively, my HTML code is messed up, > but I > am pretty sure this is more or less a simple task. > > I am working in Python 2.6.5. Many thanks in advance > > Spyros >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor