Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #36251
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <yacinechaouche@yahoo.com> |
| 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; 'output': 0.04; 'modified': 0.05; 'modify': 0.05; 'skip:$ 30': 0.07; 'subject:How': 0.09; '"%s"': 0.09; 'answering': 0.09; 'lines:': 0.09; 'script,': 0.09; 'subject:script': 0.09; 'def': 0.10; 'kurt': 0.11; 'programmer': 0.11; 'advance.': 0.15; 'modification': 0.15; "'';": 0.16; "(i'm": 0.16; 'columns': 0.16; 'item)': 0.16; 'received:98.138.89.199': 0.16; 'rewriting': 0.16; 'script?': 0.16; 'test.': 0.17; '>>>': 0.18; 'to:name:python-list@python.org': 0.20; '>>>': 0.22; 'skip:$ 20': 0.22; '>': 0.23; 'to:2**1': 0.23; "i've": 0.23; 'tried': 0.25; 'header:In-Reply-To:1': 0.25; 'skip:" 20': 0.26; 'question': 0.27; 'to?': 0.27; 'lines': 0.28; 'url:mailman': 0.29; 'convert': 0.29; 'skip:& 10': 0.29; "i'm": 0.29; "skip:' 10": 0.30; 'url:python': 0.32; 'could': 0.32; 'skip:_ 30': 0.32; 'print': 0.32; 'url:listinfo': 0.32; 'to:addr:python-list': 0.33; 'skip:& 20': 0.33; 'text': 0.34; 'reply-to:addr:yahoo.com': 0.34; 'table': 0.35; 'subject:?': 0.35; 'subject:': 0.36; 'but': 0.36; 'url:org': 0.36; 'apple': 0.36; 'email addr:python.org': 0.36; 'thank': 0.36; 'item': 0.37; 'sent:': 0.37; 'subject:: ': 0.38; 'green': 0.38; 'from:': 0.38; 'skip:l 20': 0.38; 'several': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'skip:" 10': 0.40; 'url:mail': 0.40; 'your': 0.60; 'places': 0.61; 'first': 0.61; 'email name:python-list': 0.62; 'different': 0.63; 'show': 0.63; 'price': 0.66; 'url:content': 0.66; 'header:Reply-To:1': 0.68; 'received:41': 0.73; 'subject:this': 0.84; '2013': 0.84 |
| X-Yahoo-Newman-Property | ymail-3 |
| X-Yahoo-Newman-Id | 699320.80976.bm@omp1057.mail.ne1.yahoo.com |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1357480908; bh=hj7B2ZV1QopygpX2q0o1Fa9Ck7OEBi+n7/v56eXmVyQ=; 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=XxiiEPvpimkjpjH1C0z0g5lj6wWh0OnQgtbJRkNymHSqC2K0PtxKubYCtSazGboKoTxIA/saX3iVMf5m5RHpMjLGxkCrZyNRvfccU6WiocRWheSWkDwFrmM/Nj/ZscgThxBt7M1QGNVgjNuNJDERRAlHUfmC3XFdmOhLN5EoQ0c= |
| 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=T3SZI2bHkb6MiKy/ZTjvG93rnQQk90qJIJtxLyNyE4JpOhjV615uuC0/XFXcqiMukZN5OinrN3s0twctmJy8Ljdth9it27hSQuGe9pCHvzeOHbV9Ral4RrAo8/xiGcE47sxP/jvJP8Lju5UQm9yxpZnOGQMmfIDmALqu0bLoa1I=; |
| X-YMail-OSG | By.oYJcVM1nZmS.wjMuQfmRRy3wBNSUvxrFsywJ6jGrGZ7t KKytRCUeQQN9l4Y01C7JaL_SqMPjUfVcMLR4XsveP7uPAgdD_Su4I4OnXZDA u3Uux6WJJBIhPMd3mRUyHgVQss7XIcNxZ530XzVdhJDA7eZCCOytBHnrS9kE o.Fwi296QCXFw_Ts6ukJKD46ROVOTQfiP0K2heIYRKJSOSkjYTb8RE48wtuO Po_ylfmyMmaVpZHWMQ4HGSnz4wWSJxgZzcOZs_k8ZItRBq2bqhkVMXtZaBwx gP86WFjkyRrg9CMFNaXKJE4a52ZaJLeZVEBrS1e2WdupaR0f46V4jifeydBw fk4SpAeUxIae.IjjdgcEc72IPVLg14.qfMF33qUBAH24.Oe3oWa.XfxXYW9B WknniccoMBd7TNW9gV6_AIWLE9DXRPHIQwJpbQrmW0YRk5E2hhqZjLGFYijt u.y63TVKZ71csFy1MEZToqPkdpMQ9nKqxIKckX0DIWC3Ix.HonPqAhrXi6r7 hotfoDqHHEjUGSwMDKUQ2gJfAqvpz9nr_cR1Nyq2BxQk5QqS4S6HIwaU4zHF FIpgAgrboshcsqsPZ0cq7OEa_FTR3r6X1Dai1aOR84t4IxLOH.QgSYQOOaJk Q.vPbjDheBSQmYAY- |
| X-Rocket-MIMEInfo | 001.001, CgpXZWxsLCBJJ20gbm90IGFuc3dlcmluZyB5b3VyIHF1ZXN0aW9uIHNpbmNlIEkgYW0gcmV3cml0aW5nIHRoZSBzY3JpcHQsIGJlY2F1c2UgSSBwcmVmZXIgaXQgdGhpcyB3YXkgOikKCmRlZiBhZGRsaW5lKGxpbmUpOgrCoMKgwqAgcmV0dXJuICI8dHI.JXM8L3RyPlxuIiAlIGxpbmUKCmRlZiBhZGRjb2x1bW4oaXRlbSxuYl9jb2x1bW5zKToKwqDCoMKgIGlmIG5iX2NvbHVtbnMgIT0gMzoKwqDCoMKgwqDCoMKgwqAgcmV0dXJuICI8dGQgY29sc3Bhbj0nJXMnPiVzPC90ZD4iICUgKDMgLSBuYl9jb2x1bW5zICsBMAEBAQE- |
| X-Mailer | YahooMailWebService/0.8.129.483 |
| References | <50e97123$0$294$14726298@news.sunsite.dk> <mailman.161.1357477260.2939.python-list@python.org> <50e97e4c$0$294$14726298@news.sunsite.dk> |
| Date | Sun, 6 Jan 2013 06:01:47 -0800 (PST) |
| From | chaouche yacine <yacinechaouche@yahoo.com> |
| Subject | Re: How to modify this script? |
| To | Kurt Hansen <kurt@ugyldig.invalid>, "python-list@python.org" <python-list@python.org> |
| In-Reply-To | <50e97e4c$0$294$14726298@news.sunsite.dk> |
| MIME-Version | 1.0 |
| Content-Type | multipart/alternative; boundary="318864283-659537238-1357480907=:76364" |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| Reply-To | chaouche yacine <yacinechaouche@yahoo.com> |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.168.1357481051.2939.python-list@python.org> (permalink) |
| Lines | 111 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1357481051 news.xs4all.nl 6930 [2001:888:2000:d::a6]:33919 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:36251 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Well, I'm not answering your question since I am rewriting the script, because I prefer it this way :)
def addline(line):
return "<tr>%s</tr>\n" % line
def addcolumn(item,nb_columns):
if nb_columns != 3:
return "<td colspan='%s'>%s</td>" % (3 - nb_columns + 1, item)
return "<td>%s</td>" % item
output = "<table>\n"
for line in file("data.txt"):
items = line.strip().split("\t")
columns = ""
for item in items :
columns += addcolumn(item,len(items))
output += addline(columns)
output += "</table>"
print output
printed
>>> <table>
<tr><td colspan='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>
>>>
________________________________
From: Kurt Hansen <kurt@ugyldig.invalid>
To: python-list@python.org
Sent: Sunday, January 6, 2013 2:38 PM
Subject: Re: How to modify this script?
Den 06/01/13 13.58, chaouche yacine skrev:
> if len(columns) != 3:
> colspan = 3 - len(columns) + 1
> output += '<td colspan=%s>' % (colspan) + item + '</td> '
>
> I did not test. Use with caution.
I've tried to put it in several different places in the script, but with
no luck; remember that I'm not experienced, so please tell me exactly
where it's surposed to be inserted. Could you eventually show the
complete modified script?
>
> ------------------------------------------------------------------------
> *From:* Kurt Hansen <kurt@ugyldig.invalid>
> *To:* python-list@python.org
> *Sent:* Sunday, January 6, 2013 1:42 PM
> *Subject:* How to modify this script?
>
> http://www.tuxradar.com/content/save-time-gedit-snippets:
>
> To convert tab-separated text lines into a HTML-table:
>
> $<
> lines = $GEDIT_SELECTED_TEXT.split("\n");
> output = '<table\>\n';
>
> for line in lines:
> output += '<tr\>';
>
> columns = line.split("\t");
> for item in columns:
> output += '<td\>' + item + '</td\> '
>
> output += '</tr\>\n';
>
> output += '</table\>';
> return output
> >
>
> I would like to make a small modification (I'm not a programmer myself).
> Let's say I have these lines:
>
> Price table
> 1 <tab> Green apple <tab> $1
> 5 <tab> Green apples <tab> $4
> 10 <tab> Green apples <tab> $7
>
> Since there's only one "field" in the first line, I want this output:
>
> <tr><td colspan="3">Price table</td></tr>
>
> - insted of
>
> <tr><td>Price table</td></tr>
>
> How to? Thank you i advance.
> -- Venlig hilsen
> Kurt Hansen
> -- http://mail.python.org/mailman/listinfo/python-list
>
>
--
Venlig hilsen
Kurt Hansen
--
http://mail.python.org/mailman/listinfo/python-list
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 13:42 +0100
Re: How to modify this script? Chris Angelico <rosuav@gmail.com> - 2013-01-06 23:52 +1100
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 14:34 +0100
Re: How to modify this script? Chris Angelico <rosuav@gmail.com> - 2013-01-07 00:44 +1100
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 15:03 +0100
Re: How to modify this script? Chris Angelico <rosuav@gmail.com> - 2013-01-07 01:20 +1100
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 15:30 +0100
Re: How to modify this script? Chris Angelico <rosuav@gmail.com> - 2013-01-07 01:41 +1100
Re: How to modify this script? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2013-01-08 15:18 +0100
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-09 10:21 +0100
Re: How to modify this script? chaouche yacine <yacinechaouche@yahoo.com> - 2013-01-06 04:58 -0800
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 14:38 +0100
Re: How to modify this script? chaouche yacine <yacinechaouche@yahoo.com> - 2013-01-06 06:01 -0800
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 15:21 +0100
Re: How to modify this script? chaouche yacine <yacinechaouche@yahoo.com> - 2013-01-06 07:12 -0800
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-07 17:42 +0100
Re: How to modify this script? chaouche yacine <yacinechaouche@yahoo.com> - 2013-01-08 07:31 -0800
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-09 10:07 +0100
Re: How to modify this script? chaouche yacine <yacinechaouche@yahoo.com> - 2013-01-09 02:23 -0800
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-09 12:04 +0100
Re: How to modify this script? chaouche yacine <yacinechaouche@yahoo.com> - 2013-01-09 10:25 -0800
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-11 05:35 +0100
Re: How to modify this script? Subimal Deb <subimal.deb@gmail.com> - 2013-01-06 06:22 -0800
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 15:40 +0100
Re: How to modify this script? Chris Angelico <rosuav@gmail.com> - 2013-01-07 01:52 +1100
Re: How to modify this script? Kurt Hansen <kurt@ugyldig.invalid> - 2013-01-06 16:05 +0100
Re: How to modify this script? Gertjan Klein <gklein@xs4all.nl> - 2013-01-07 18:56 +0100
Re: How to modify this script? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2013-01-08 15:22 +0100
Re: How to modify this script? Gertjan Klein <gklein@xs4all.nl> - 2013-01-08 17:22 +0100
csiph-web