Printer list value problem
Mike
miguelcoam at gmail.com
Tue Jan 14 14:54:22 EST 2014
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 at example.com;user1;lastName;Name
>
> > user2 at example.com;user2;lastName;Name
>
> > [........]
>
> >
>
> > But when execute the script I view the print is only the last user
>
> >
>
> > [........]
>
> > ca user2 at example.com displayName 'user2' sn 'lastName' cn 'Name'
>
> > [........]
>
> >
>
> > And I need the next printer
>
> >
>
> > [........]
>
> > ca user1 at example.com displayName 'User1' sn ''lastName" cn 'Name'
>
> > ca user1 at 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
More information about the Python-list
mailing list