<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt">Well tell me how do you use this script in gedit, are you using it as a plugin ? are you putting this code somewhere ? I'll try to do the same on my side and try to understand how it works.<br><br><br><div><span><br></span></div><div><br></div> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div dir="ltr"> <font size="2" face="Arial"> <hr size="1"> <b><span style="font-weight:bold;">From:</span></b> Kurt Hansen <kurt@ugyldig.invalid><br> <b><span style="font-weight: bold;">To:</span></b> python-list@python.org <br> <b><span style="font-weight: bold;">Sent:</span></b> Monday, January 7, 2013 5:42 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: How to modify this script?<br> </font>
</div> <br>
Den 06/01/13 16.12, chaouche yacine skrev:<br>> I'm not confident this would run on gedit. It works on a python<br>> interpreter if you have a file named data.txt in the same directory<br>> containing your sample data.<br>><br>> It surely has to do with how gedit works then, because the "$" sign<br>> isn't used in python, this business should be a gedit convention. And<br>> sorry, I can't help on that, I'm not a user of gedit myself. Fortunately<br>> others have answered and I beleive one of the solutions worked for you.<br><br>It does not seem to be the case :-(<br><br>Thank you for trying to help.<br><br>> ------------------------------------------------------------------------<br>> *From:* Kurt Hansen <<a ymailto="mailto:kurt@ugyldig.invalid" href="mailto:kurt@ugyldig.invalid">kurt@ugyldig.invalid</a>><br>> *To:* <a ymailto="mailto:python-list@python.org"
href="mailto:python-list@python.org">python-list@python.org</a><br>> *Sent:* Sunday, January 6, 2013 3:21 PM<br>> *Subject:* Re: How to modify this script?<br>><br>> Den 06/01/13 15.01, chaouche yacine wrote:<br>> > Well, I'm not answering your question since I am rewriting the script,<br>> > because I prefer it this way :)<br>> ><br>> > def addline(line):<br>> > return "<tr>%s</tr>\n" % line<br>> [cut]<br>><br>> I surpose I shall put your code between $< and >?<br>><br>> > printed<br>> ><br>> > >>> <table><br>> > <tr><td colspan='3'>Price table</td></tr><br>> > <tr><td>1 </td><td> Green apple </td><td> $1</td></tr><br>> > <tr><td>5 </td><td> Green
apples </td><td> $4</td></tr><br>> > <tr><td>10 </td><td> Green apples </td><td> $7</td></tr><br>> > </table><br>> > >>><br>><br>> Aha, so you tested it yourself?<br>><br>> When running this in Gedit on four lines of tab-separated text the<br>> output is:<br>><br>> %s</tr>\n" % line<br>><br>> def addcolumn(item,nb_columns):<br>> if nb_columns != 3:<br>> return "<td colspan='%s'>%s</td>" % (3 - nb_columns + 1, item)<br>> return "<td>%s</td>" % item<br>><br>> output = "<table>\n"<br>> for line in file("data.txt"):<br>> items = line.strip().split("\t")<br>> columns = ""<br>> for item in items :<br>>
columns += addcolumn(item,len(items))<br>> output += addline(columns)<br>><br>><br>> output += "</table>"<br>> print output<br>> ><br>> -- Venlig hilsen<br>> Kurt Hansen<br>> -- http://mail.python.org/mailman/listinfo/python-list<br>><br>><br><br><br>-- <br>Venlig hilsen<br>Kurt Hansen<br>-- <br><a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br><br><br> </div> </div> </div></body></html>