Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!hq-usenetpeers.eweka.nl!81.171.88.250.MISMATCH!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'interpreter': 0.04; 'output': 0.04; 'modify': 0.05; 'convention.': 0.07; 'subject:How': 0.09; 'python': 0.09; '"%s"': 0.09; '%s\\n"': 0.09; 'answering': 0.09; 'script,': 0.09; 'subject:script': 0.09; 'def': 0.10; 'kurt': 0.11; 'columns': 0.16; 'item)': 0.16; 'rewriting': 0.16; 'script?': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'to:name:python-list@python.org': 0.20; '>>>': 0.22; 'skip:$ 20': 0.22; 'skip:% 10': 0.22; 'sorry,': 0.22; '>': 0.23; 'to:2**1': 0.23; 'header:In-Reply- To:1': 0.25; 'skip:" 20': 0.26; 'question': 0.27; 'lines': 0.28; 'run': 0.28; 'received:98.138.87': 0.29; 'url:mailman': 0.29; 'skip:& 10': 0.29; "i'm": 0.29; 'worked': 0.30; 'code': 0.31; 'url:python': 0.32; 'file': 0.32; 'running': 0.32; 'skip:_ 30': 0.32; 'print': 0.32; 'url:listinfo': 0.32; 'surely': 0.33; 'to:addr:python-list': 0.33; 'skip:& 20': 0.33; 'that,': 0.34; "can't": 0.34; 'text': 0.34; 'reply-to:addr:yahoo.com': 0.34; 'table': 0.35; 'subject:?': 0.35; 'subject:': 0.36; 'url:org': 0.36; 'apple': 0.36; 'data.': 0.36; 'email addr:python.org': 0.36; 'should': 0.36; 'item': 0.37; 'sent:': 0.37; 'subject:: ': 0.38; 'green': 0.38; 'from:': 0.38; 'skip:l 20': 0.38; 'to:addr:python.org': 0.39; 'skip:" 10': 0.40; 'help': 0.40; 'url:mail': 0.40; 'your': 0.60; 'you.': 0.61; 'containing': 0.61; 'email name:python-list': 0.62; 'between': 0.63; 'price': 0.66; 'header:Reply-To:1': 0.68; 'business': 0.70; 'received:41': 0.73; 'subject:this': 0.84; '2013': 0.84; 'fortunately': 0.84; 'yourself?': 0.84 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 668118.95638.bm@omp1002.mail.ne1.yahoo.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1357485163; bh=qAqz2VmxXcXUIbvqayRRVB4gZcJVb9GbrAyE4YzW+98=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=Kf9iqxQ3AtSbmvFDwirwfz+RT46HTGWNBf5TwfLXk5WRrwPHlTkEIj8bHYAIeMbsYpKo1JB1oSrAnJXUSN6g78AJQpGr18NIKa+UQ2Ck19C50XTwDPwRMrJdv+w3RmsSbJHfL+N49wGC8MohvyZ7XS8Bf7Lg4txVxlH3JJb3gKU= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=4Rr4rQnxRT63adeHc8d6rO5UjM/1zVxs2WoF2dBOQPV6kEhWvl5Orkk+drvzKXdjxU92ItZFN/BvWgMNJmgz3TQV54fuAAH3Knu8OqDtKb7zCWJspXm61wjHAJAG08HCq5N+/a4uR4Pffcq3QLdyuy8eUYVnENQVAjuYEBsAtD4=; X-YMail-OSG: IPBgmiEVM1kNvvBJd5rZ1EzG5eObBQrF5xIW9_07xN7b8fq w4nzJ5chthxVE5OimlCfPEmVGDO4fFgfmcesyan41m0hqV4sZn2_.8ShTOO_ 9rUIiJvRYjIbL0USFHdgYq_YTVG.C7IXz9_GGC_syZh052vb2s7aK0OqM6Kv pRncUcnOYzBRkbxSqUdOgJpaGluVI05B2pTUHBO0Z1MPZvbAgfaCRFQUiTgl 2aBkDyr1YJc9IpmbRmB.0VJl7QK4A9RdP1eTsiO0Hklkn6YA_DTy5PYBOMqH 8aBJUwPSGL7ejg1svwLZ76Kpm_1yO7maPqllcngIV5q69yF9YfzM7GxaDF4E MjdezO0EEXHPUqHY5EeGFEJqERNe_CJQ8.VUf9I8.7qzSiX7Tax9YqDw7mR8 wUc454heAD73Os.ftwBYHkacwgIhEJT8Zg9871_0wEun_Ecv7CyKj_03LyF0 .bPS8wDEmQmvDxt6LvGFy6lWTKCqd8ZW5niFlsaOYJc7Wb_alVdW_HX5oSl7 nd7W9gLP2AfFtF7_c1lPYmZsU2_pi X-Rocket-MIMEInfo: 001.001, SSdtIG5vdCBjb25maWRlbnQgdGhpcyB3b3VsZCBydW4gb24gZ2VkaXQuIEl0IHdvcmtzIG9uIGEgcHl0aG9uIGludGVycHJldGVyIGlmIHlvdSBoYXZlIGEgZmlsZSBuYW1lZCBkYXRhLnR4dCBpbiB0aGUgc2FtZSBkaXJlY3RvcnkgY29udGFpbmluZyB5b3VyIHNhbXBsZSBkYXRhLgoKSXQgc3VyZWx5IGhhcyB0byBkbyB3aXRoIGhvdyBnZWRpdCB3b3JrcyB0aGVuLCBiZWNhdXNlIHRoZSAiJCIgc2lnbiBpc24ndCB1c2VkIGluIHB5dGhvbiwgdGhpcyBidXNpbmVzcyBzaG91bGQgYmUgYSBnZWRpdCBjb252ZW4BMAEBAQE- X-Mailer: YahooMailWebService/0.8.129.483 References: <50e97123$0$294$14726298@news.sunsite.dk> <50e97e4c$0$294$14726298@news.sunsite.dk> <50e9885e$0$294$14726298@news.sunsite.dk> Date: Sun, 6 Jan 2013 07:12:43 -0800 (PST) From: chaouche yacine Subject: Re: How to modify this script? To: Kurt Hansen , "python-list@python.org" In-Reply-To: <50e9885e$0$294$14726298@news.sunsite.dk> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="264668936-1014338162-1357485163=:11230" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: chaouche yacine List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 78 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1357485172 news.xs4all.nl 6965 [2001:888:2000:d::a6]:42335 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:36262 --264668936-1014338162-1357485163=:11230 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable I'm not confident this would run on gedit. It works on a python interpreter= if you have a file named data.txt in the same directory containing your sa= mple data.=0A=0AIt surely has to do with how gedit works then, because the = "$" sign isn't used in python, this business should be a gedit convention. = And sorry, I can't help on that, I'm not a user of gedit myself. Fortunatel= y others have answered and I beleive one of the solutions worked for you.= =0A=0A=0A=0A________________________________=0A From: Kurt Hansen =0ATo: python-list@python.org =0ASent: Sunday, January 6, 2013= 3:21 PM=0ASubject: Re: How to modify this script?=0A =0ADen 06/01/13 15.01= , chaouche yacine wrote:=0A> Well, I'm not answering your question since I = am rewriting the script,=0A> because I prefer it this way :)=0A> =0A> def a= ddline(line):=0A>=A0 =A0 =A0 return "%s\n" % line=0A[cut]=0A=0AI s= urpose I shall put your code between $< and >?=0A=0A> printed=0A> =0A>=A0 >= >> =0A> =0A> =0A> =0A> =0A>
Price table
1 Green apple $1
5 Green ap= ples $4
10 Green apples = $7
=0A>=A0 >>>=0A=0AAha, so you tested it yourself?= =0A=0AWhen running this in Gedit on four lines of tab-separated text the ou= tput is:=0A=0A%s\n" % line=0A=0Adef addcolumn(item,nb_columns):=0A=A0 = =A0 if nb_columns !=3D 3:=0A=A0 =A0 =A0 =A0 return "%s" % (3 - nb_columns + 1, item)=0A=A0 =A0 return "%s" % item=0A= =0Aoutput =3D "\n"=0Afor line in file("data.txt"):=0A=A0 =A0 items = =3D line.strip().split("\t")=0A=A0 =A0 columns =3D ""=0A=A0 =A0 for item in= items :=0A=A0 =A0 =A0 =A0 columns +=3D addcolumn(item,len(items))=0A=A0 = =A0 output=A0 +=3D addline(columns)=0A=0A=0Aoutput +=3D "
"=0Aprint = output=0A>=0A-- Venlig hilsen=0AKurt Hansen=0A-- http://mail.python.org/mai= lman/listinfo/python-list --264668936-1014338162-1357485163=:11230 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
I'm not confident thi= s would run on gedit. It works on a python interpreter if you have a file n= amed data.txt in the same directory containing your sample data.

It = surely has to do with how gedit works then, because the "$" sign isn't used= in python, this business should be a gedit convention. And sorry, I can't = help on that, I'm not a user of gedit myself. Fortunately others have answe= red and I beleive one of the solutions worked for you.

<= div style=3D"font-family: times new roman, new york, times, serif; font-siz= e: 12pt;">

From: Kurt Hansen <k= urt@ugyldig.invalid>
To: python-list@python.org
Sent: Sunday, January 6, 2013 3:21 PM
Subject: Re: How to modify this script?

=0ADen 06/01/13 15.01, chaouche yacine wrote:
> Well, I'm not = answering your question since I am rewriting the script,
> because I = prefer it this way :)
>
> def addline(line):
>  &nb= sp;   return "<tr>%s</tr>\n" % line
[cut]

I surp= ose I shall put your code between $< and >?

> printed
&g= t;
>  >>> <table>
> <tr><td colsp= an=3D'3'>Price table</td></tr>
> <tr><td>1= </td><td> Green apple </td><td> $1</td></= tr>
> <tr><td>5 </td><td> Green apples <= ;/td><td> $4</td></tr>
> <tr><td>10 = </td><td> Green apples </td><td> $7</td></= tr>
> </table>
>  >>>

Aha, so you= tested it yourself?

When running this in Gedit on four lines of tab-separated text the output is:

%s</tr>\n" % line

de= f addcolumn(item,nb_columns):
    if nb_columns !=3D 3:
&nb= sp;       return "<td colspan=3D'%s'>%s</td>" % = (3 - nb_columns + 1, item)
    return "<td>%s</td>= " % item

output =3D "<table>\n"
for line in file("data.txt"= ):
    items =3D line.strip().split("\t")
    col= umns =3D ""
    for item in items :
      &n= bsp; columns +=3D addcolumn(item,len(items))
    output  = +=3D addline(columns)


output +=3D "</table>"
print outp= ut
>
-- Venlig hilsen
Kurt Hansen
-- http://mail.python.org/= mailman/listinfo/python-list


--264668936-1014338162-1357485163=:11230--