I have a text file called test.txt which contains data in this format
....
a|b|c|d|e
a1|b2|c3|d4|e5
a3|b5|c2|d1|e3
....
I want to get the values of each column into lists: something like this
list1=[a,a1,a3]
list2=[b,b2,b5]
I managed to get this done by doing this:
list1,list2,list3,list4,list5 = ([] for i in range(5))
for line in open('test.txt','r'):
temp=line.split('|')
list1.append(temp[0])
list2.append(temp[1])
list3.append(temp[2])
list4.append(temp[3])
list5.append(temp[4].strip())
Is there shorter way to append the values to each list? I can only think of using 1 line for each list as above.