Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '[0]': 0.09; 'email addr:example.com': 0.09; 'executed': 0.09; 'f.close()': 0.09; 'finished.': 0.09; "'rb')": 0.16; 'csv': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'wrote:': 0.18; "skip:' 30": 0.19; 'value.': 0.19; 'thanks.': 0.20; 'example': 0.22; 'import': 0.22; 'mike': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'subject:problem': 0.24; 'script': 0.25; 'header:In-Reply-To:1': 0.27; '(this': 0.29; '[2]': 0.30; 'statement': 0.30; 'subject:list': 0.30; 'file': 0.32; 'open': 0.33; 'reader': 0.33; 'skip:# 10': 0.33; 'moment': 0.34; 'problem': 0.35; 'but': 0.35; 'next': 0.36; 'list': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'you.': 0.62; 'name': 0.63; 'here': 0.66; 'close': 0.67; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; "'for'": 0.84; "'with'": 0.84; 'reply- to:addr:python.org': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=CfYxutbl c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=5FYZ9MsUIQAA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=cYen-vxlNLUA:10 a=A1X0JdhQAAAA:8 a=E17dc5O1p3ZNnNCpkm4A:9 a=QEXdDO2ut3YA:10 a=Y6qChIQXU1wA:10 X-AUTH: mrabarnett:2500 Date: Tue, 14 Jan 2014 19:32:49 +0000 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Printer list value problem References: <6139406d-9ccc-41b2-8aa8-7f6fd2431366@googlegroups.com> In-Reply-To: <6139406d-9ccc-41b2-8aa8-7f6fd2431366@googlegroups.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org 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: 52 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389727971 news.xs4all.nl 2963 [2001:888:2000:d::a6]:33221 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63929 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. >