Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63934
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'mrab': 0.05; '[0]': 0.09; 'email addr:example.com': 0.09; 'executed': 0.09; 'f.close()': 0.09; 'finished.': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'language.': 0.14; "'rb')": 0.16; 'csv': 0.16; 'escribi\xf3:': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'row)': 0.16; 'spacing': 0.16; 'prevent': 0.16; 'language': 0.16; 'wrote:': 0.18; "skip:' 30": 0.19; 'value.': 0.19; 'thanks.': 0.20; '>>>': 0.22; 'example': 0.22; 'import': 0.22; 'mike': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'subject:problem': 0.24; 'url:moin': 0.24; 'script': 0.25; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; '(this': 0.29; '[2]': 0.30; 'statement': 0.30; 'subject:list': 0.30; 'url:wiki': 0.31; 'file': 0.32; 'open': 0.33; 'url:python': 0.33; 'reader': 0.33; 'skip:# 10': 0.33; 'moment': 0.34; 'problem': 0.35; 'but': 0.35; 'next': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'list': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'remove': 0.60; 'read': 0.60; 'above,': 0.60; 'you.': 0.62; 'name': 0.63; 'our': 0.64; 'here': 0.66; 'close': 0.67; "'for'": 0.84; "'with'": 0.84; '(print': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
| Subject | Re: Printer list value problem |
| Date | Tue, 14 Jan 2014 20:03:06 +0000 |
| References | <6139406d-9ccc-41b2-8aa8-7f6fd2431366@googlegroups.com> <mailman.5470.1389727971.18130.python-list@python.org> <75028f66-b36c-4b1d-b055-3beb05b66f8c@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Gmane-NNTP-Posting-Host | host-92-24-218-28.ppp.as43234.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
| In-Reply-To | <75028f66-b36c-4b1d-b055-3beb05b66f8c@googlegroups.com> |
| 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 | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5474.1389729800.18130.python-list@python.org> (permalink) |
| Lines | 123 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1389729800 news.xs4all.nl 2968 [2001:888:2000:d::a6]:49750 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:63934 |
Show key headers only | View raw
On 14/01/2014 19:54, Mike wrote:
> El martes, 14 de enero de 2014 16:32:49 UTC-3, MRAB escribió:
>> On 2014-01-14 19:24, Mike wrote:
>>
>>> Hello,
>>
>>> I confudsed,need printer the value of list (this is reaer from csv) . The reader is ok, but my problem is in the print moment because printer only the last value. For example my csv is:
>>
>>>
>>
>>> [........]
>>
>>> user1@example.com;user1;lastName;Name
>>
>>> user2@example.com;user2;lastName;Name
>>
>>> [........]
>>
>>>
>>
>>> But when execute the script I view the print is only the last user
>>
>>>
>>
>>> [........]
>>
>>> ca user2@example.com displayName 'user2' sn 'lastName' cn 'Name'
>>
>>> [........]
>>
>>>
>>
>>> And I need the next printer
>>
>>>
>>
>>> [........]
>>
>>> ca user1@example.com displayName 'User1' sn ''lastName" cn 'Name'
>>
>>> ca user1@example.com displayName 'User2' sn ''lastName" cn 'Name'
>>
>>> [........]
>>
>>>
>>
>>> My script is
>>
>>>
>>
>>> [........]
>>
>>> #!/usr/bin/python
>>
>>> import csv
>>
>>> with open ('users.csv', 'rb') as f:
>>
>>>
>>
>>> reader = csv.reader (f, delimiter=';' ) #delimiter tabulador
>>
>>> for row in reader:
>>
>>>
>>
>>> mail = row [0]
>>
>>> name = row [3]
>>
>>> lastname = row [2]
>>
>>>
>>
>>
>>
>> This line is indented the same amount as the 'for' loop, which means
>>
>> that it will be executed after the loop has finished.
>>
>>
>>
>>> print "ma {} displayName '{}' sn '{}'".format(mail,name,lastname)
>>
>>>
>>
>> You don't need to close the file here because the 'with' statement will
>>
>> do that for you.
>>
>>
>>
>>> f.close()
>>
>>> [........]
>>
>>>
>>
>>>
>>
>>> Thanks.
>>
>>>
>
> Hello MRAB,
> I remove the "f.close" and after execute the script but still i have the same result (print the last row)
>
> Thanks
>
Your print statement needs to be inside the for loop, you currently have
it after the loop has finished.
Would you also please read and action this
https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing the
double line spacing above, thanks.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Printer list value problem Mike <miguelcoam@gmail.com> - 2014-01-14 11:24 -0800
Re: Printer list value problem MRAB <python@mrabarnett.plus.com> - 2014-01-14 19:32 +0000
Re: Printer list value problem Mike <miguelcoam@gmail.com> - 2014-01-14 11:54 -0800
Re: Printer list value problem Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-14 20:03 +0000
Re: Printer list value problem Tim Chase <python.list@tim.thechases.com> - 2014-01-14 13:38 -0600
csiph-web