Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #37781

Re: Formatting a column's value output

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 <joel.goldstick@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'value,': 0.03; 'column': 0.07; 'data:': 0.07; '&quot;': 0.09; "'''": 0.09; 'separately': 0.09; 'url:%s': 0.09; 'cc:addr:python-list': 0.10; '(the': 0.15; 'count)': 0.16; 'hits': 0.16; 'item)': 0.16; 'only?': 0.16; 'row': 0.16; 'seperate': 0.16; 'subject:Formatting': 0.16; 'wrote:': 0.17; 'jan': 0.18; 'email addr:gmail.com&gt;': 0.20; 'work,': 0.22; 'cc:2**0': 0.23; '&gt;': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'values': 0.26; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; 'coded': 0.29; 'url:mailman': 0.29; 'skip:& 10': 0.29; "skip:' 10": 0.30; 'url:python': 0.32; 'print': 0.32; 'url:listinfo': 0.32; 'right?': 0.33; 'skip:& 20': 0.33; 'received:google.com': 0.34; 'pm,': 0.35; 'too.': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'url:org': 0.36; 'possible': 0.37; 'two': 0.37; 'item': 0.37; 'rather': 0.37; 'received:209': 0.37; 'far': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'apply': 0.39; 'url:mail': 0.40; 'link': 0.60; 'email addr:yahoo.com': 0.61; 'skip:\xc2 10': 0.62; 'within': 0.64; '8bit%:100': 0.70; '8bit%:92': 0.70; '2013': 0.84; 'subject:value': 0.84; 'url:show': 0.84; 'joel': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=aZedayT+MvEUlJJ0mKjGayqbRd9jSnlSvJI3/mE3mqw=; b=zGJEEJ4fW2PDkVjvIQEh3T2HgazvbfnhnU3927FqScqrm6Ok9H6/v5jvRIUQnu+2wA Rt48pCHrRWMCwFDbytoAJrJEj2lGoyNVYXdLniXS65txwIHxsxBJyC8EIFROWlJLaQDK YPhNVnf7OwjIeYMnsAfUokW0anQY1qmRd6q9eJ+95vaCKkPLigRUKZJwVxvpmAVIAWjt T6uM/wf4yTm4fDRcNA2d5fuDr5jv24JTaqjwCsDACKSwIOhnxaLU2WbQcqzHuzGiOfI0 lZsqM6kaC+7arwwub5IMmb4wKhrxf04+JA7vwBy+xY9a4zBWsawYI8IxfI61OuyhF9Rf 4M8w==
MIME-Version 1.0
X-Received by 10.52.19.200 with SMTP id h8mr4517983vde.60.1359311802298; Sun, 27 Jan 2013 10:36:42 -0800 (PST)
In-Reply-To <f0e08aad-3c69-4ba0-82d0-91652997c7d4@googlegroups.com>
References <6ad78df4-0ec0-4760-8f5a-5ecf129c5e65@googlegroups.com> <mailman.1086.1359223462.2939.python-list@python.org> <d543dccf-af7a-4efd-adc5-13d9ef080c1e@googlegroups.com> <mailman.1090.1359239220.2939.python-list@python.org> <a8690843-35b0-423e-a79d-f2b6c1991be6@googlegroups.com> <63edba3c-55af-4c4c-a311-4188891bfdf0@googlegroups.com> <f0e08aad-3c69-4ba0-82d0-91652997c7d4@googlegroups.com>
Date Sun, 27 Jan 2013 13:36:42 -0500
Subject Re: Formatting a column's value output
From Joel Goldstick <joel.goldstick@gmail.com>
To Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com>
Content-Type multipart/alternative; boundary=20cf307ca04c1d6f3104d4497192
Cc "python-list@python.org" <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
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.1116.1359311811.2939.python-list@python.org> (permalink)
Lines 184
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1359311811 news.xs4all.nl 6917 [2001:888:2000:d::a6]:50765
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:37781

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Sun, Jan 27, 2013 at 1:05 PM, Κώστας Παπαδόπουλος
<nikos.gr33k@gmail.com>wrote:

> Τη Κυριακή, 27 Ιανουαρίου 2013 6:12:59 μ.μ. UTC+2, ο χρήστης
> ru...@yahoo.com έγραψε:
> > On 01/27/2013 02:04 AM, Ferrous Cranus wrote:
> >
> > >[...]
> >
> > >             data = cur.fetchall()
> >
> > >             for row in data:
> >
> > >                     print ( "<tr>" )
> >
> > >
> >
> > >                     for item in row:
> >
> > >                             print( '''<td>  <a href='http://www.%s?show=log'>%s</a>
>  </td>''' % (item, item) )
> >
> > >[...]
> >
> > > Okey, so far BUT i want the url linking to happen only for the URL
> column's
> >
> > > value, and not for the hits column too. How do i apply the url link to
> the
> >
> > > URL column's value only?
> >
> >
> >
> > Ferrous,
> >
> >
> >
> > 'row' has two items (the url and the hit count) in it, right?
> >
> > So print each separately rather than in a loop:
> >
> >
> >
> >     data = cur.fetchall()
> >
> >     for row in data:
> >
> >       url = row[0]
> >
> >       hits = row[1]
> >
> >         print ( "<tr>" )
> >
> >         print( "<td>  <a href='http://www.%s?show=log'>%s</a>  </td>: %
> (url, hits) )
>
> Yes that can work, but i want to ask you if its possible to do the same
> thing from within the loop as i have it coded it until now.
>
> Is there a way to seperate the values within the loop?
>

for row in data:
    print( "<td>  <a href='http://www.%s?show=log'>%s</a>  </td>: " %
(row[0], row[1]) )

> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-26 09:51 -0800
  Re: Formatting a column's value output Chris Angelico <rosuav@gmail.com> - 2013-01-27 05:04 +1100
    Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-26 11:41 -0800
      Re: Formatting a column's value output Michael Torrie <torriem@gmail.com> - 2013-01-26 15:26 -0700
        Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-27 01:04 -0800
          Re: Formatting a column's value output Chris Angelico <rosuav@gmail.com> - 2013-01-27 20:08 +1100
            Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-27 01:16 -0800
              Re: Formatting a column's value output Chris Angelico <rosuav@gmail.com> - 2013-01-27 20:26 +1100
                Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-27 01:30 -0800
                Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-27 01:30 -0800
            Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-27 01:16 -0800
          Re: Formatting a column's value output rurpy@yahoo.com - 2013-01-27 08:12 -0800
            Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-27 10:05 -0800
              Re: Formatting a column's value output Joel Goldstick <joel.goldstick@gmail.com> - 2013-01-27 13:36 -0500
                Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-27 10:44 -0800
                Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-27 10:44 -0800
                Re: Formatting a column's value output rurpy@yahoo.com - 2013-01-27 11:12 -0800
                Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-27 12:24 -0800
                Re: Formatting a column's value output Mitya Sirenef <msirenef@lightbird.net> - 2013-01-27 15:50 -0500
                Re: Formatting a column's value output rurpy@yahoo.com - 2013-01-27 14:27 -0800
                Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-28 01:47 -0800
                Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-28 01:44 -0800
                Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-28 01:44 -0800
            Re: Formatting a column's value output Virgil Stokes <vs@it.uu.se> - 2013-01-27 18:46 +0100
        Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-27 01:04 -0800
    Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-26 11:41 -0800
    Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-26 13:07 -0800
      Re: Formatting a column's value output Chris Angelico <rosuav@gmail.com> - 2013-01-27 09:18 +1100
        Re: Formatting a column's value output alex23 <wuwei23@gmail.com> - 2013-01-26 15:29 -0800
          Re: Formatting a column's value output Chris Angelico <rosuav@gmail.com> - 2013-01-27 10:38 +1100
          Re: Formatting a column's value output Jason Friedman <jsf80238@gmail.com> - 2013-02-03 09:18 -0800
            Re: Formatting a column's value output Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-04 06:39 +0000
    Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-26 13:07 -0800

csiph-web