Thanks for your help My intention is to create matrix based on parsed csv file. So, I would like to have a list of columns (which are also lists).
I have made the following changes and it still doesn't work. cnt = 0 p=[[], [], [], [], [], [], [], [], [], [], []] reader = csv.reader(file("f:\webserver\inp.txt"), dialect="excel", quotechar="'", delimiter='\t') for line in reader: if cnt > 6: break j = 0 for col in line: p[j].append(col) j=j+1 cnt = cnt + 1 print p Iain King wrote: > Roman wrote: > > 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)) > > What are you trying to do here? p[:0] returns a new list, of all the > elements in p up to element 0 (which is of course the empty list), > which is then appended to, but is not stored anywhere. If you want to > insert str(col) then use p.insert > > > Iain -- http://mail.python.org/mailman/listinfo/python-list