Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #47345
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <davea@davea.name> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.008 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'column': 0.07; 'problem?': 0.07; 'subject:query': 0.07; 'extracted': 0.09; 'returns,': 0.09; 'rows': 0.09; 'subject:using': 0.09; 'assume': 0.14; 'suggest': 0.14; 'between.': 0.16; 'columns': 0.16; 'csv': 0.16; 'dict': 0.16; 'mean,': 0.16; 'received:74.208.4.195': 0.16; 'skip:0 40': 0.16; 'wrote:': 0.18; 'print': 0.22; 'header:User-Agent:1': 0.23; 'either.': 0.24; 'stick': 0.24; '(or': 0.24; 'define': 0.26; 'header:In-Reply-To:1': 0.27; 'lists?': 0.31; 'prints': 0.31; 'second,': 0.31; 'supposed': 0.32; 'third': 0.33; "i'd": 0.34; 'subject:from': 0.34; 'could': 0.34; 'problem': 0.35; 'subject:with': 0.35; 'something': 0.35; 'but': 0.35; 'doubt': 0.36; 'format.': 0.36; 'module.': 0.36; 'subject:data': 0.36; 'vat': 0.36; 'list': 0.37; 'list.': 0.37; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'how': 0.40; 'tell': 0.60; 'first': 0.61; 'kind': 0.63; 'here': 0.66; 'anything.': 0.68; 'received:74.208': 0.68; 'eight': 0.74; 'presumably': 0.84; 'email addr:hotmail.com': 0.89 |
| Date | Fri, 07 Jun 2013 14:24:30 -0400 |
| From | Dave Angel <davea@davea.name> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Trying to work with data from a query using Python. |
| References | <3f8d60b3-6b92-4670-ac99-28ec6fee580b@googlegroups.com> |
| In-Reply-To | <3f8d60b3-6b92-4670-ac99-28ec6fee580b@googlegroups.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Provags-ID | V02:K0:ZHoX4SNLMeqd0cXufWROg+BLcwvQB54ugGcGY9YM4UH Y8DZRNCiJFKePd80gCZQFnLHpqhCY7siCW/f2HDeBQDHd43EkD aE8iy0BWw3Y5KFhYugXAoX2wqqluSsPvQlzSjZvfkQPKW+7x4g YMTh7Guv6bIvjbJjfWP0P1XvbrCXq1zoauyumPi+Jf4vwUBjRb 7RVYg1vqPcVUetpwEB+Z/ZxwgDGVrW6MsN8OkMWdumOhcniAku Qy/Rmt/1EYVzRQKuIJFxIAOn41Cm02mZ0eUMRgDyty/LoSoQ62 ojEzzcjEBGCWzK23Rneh+FprxmemoYl182b4MI+o8ew5BpWhQ= = |
| 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.2858.1370629538.3114.python-list@python.org> (permalink) |
| Lines | 51 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1370629538 news.xs4all.nl 15971 [2001:888:2000:d::a6]:44983 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:47345 |
Show key headers only | View raw
On 06/07/2013 01:44 PM, ethereal_robe@hotmail.com wrote:
>
<SNIP>
>
> rows = cur.fetchall()
>
> for row in rows:
> print row
>
>
>
>
> Now assume that fetchall would print the following:
I doubt if fetchall() prints anything. presumably it returns something,
extracted from the db.
>
> LOEL910624ND5 from the column vat as RFC.
> 227 from the column amount_untaxed.
>
>
> Now I would need to print that in the following format.
>
> 04|85|LOEL910624ND5|||||227|||||||||||||||
>
> 04 always goes in the first column and 85 always goes in the second, vat goes in the third and the amount_untaxed goes in the eight column but we still need to have 22 columns in total.
>
>
I don't use psycopg2, and I'd suggest few others here do either.
Since the problem has nothing to do with psycopg2, could you simplify
the problem? Whatever fetchall() returns, it's presumably either a dict
or list. Or is it a list of lists?
Find out what kind of data it is, and stub it with something like:
rows = ["ab", "127"]
Then if you define what the items in that list (or whatever) are
supposed to mean, we can tell you how to stick all those pipe-symbols
between. One likely answer would be the csv module.
--
DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Trying to work with data from a query using Python. ethereal_robe@hotmail.com - 2013-06-07 10:44 -0700
Re: Trying to work with data from a query using Python. Dave Angel <davea@davea.name> - 2013-06-07 14:24 -0400
Re: Trying to work with data from a query using Python. Walter Hurry <walterhurry@lavabit.com> - 2013-06-07 21:59 +0000
Re: Trying to work with data from a query using Python. Peter Otten <__peter__@web.de> - 2013-06-07 20:59 +0200
csiph-web