List Manipulation

Roman rgelfand2 at hotmail.com
Tue Jul 4 10:01:55 EDT 2006


I would appreciate it if somebody could tell me where I went wrong in
the following snipet:

When I run I get no result

cnt = 0
p=[]
reader = csv.reader(file("f:\webserver\inp.txt"), dialect="excel",
                         quotechar="'", delimiter='\t')
for line in reader:
    if cnt > 6:
       break
    for col in line:
       p[:0].append(str(col))
    cnt = cnt + 1

print p

when I change it to the following, I get rows back

cnt = 0
p=[]
reader = csv.reader(file("f:\webserver\inp.txt"), dialect="excel",
                         quotechar="'", delimiter='\t')
for line in reader:
    if cnt > 6:
       break
    for col in line:
       print col
    cnt = cnt + 1

print p


Thanks in advance




More information about the Python-list mailing list