I want to create a loop of zips I have sample.csv file with the below entries:
> 1 2 3 4
> a b c d
> apple banana cat dog
and have the below code:
sample= open("sample.csv)
lines = sample.readlines()
testcol = []
for l in lines:
zipped = zip(testcol ,l)
The output is:
[(('1','a'),'apple'),(('2','b'),'banana'),(('3','c'),'cat'),(('4','d'),'dog')]
but what i want is:
[('1','a','apple'),('2','b','banana'),('3','c','cat'),('4','d','dog')]
The reason why i have to put it in loops is because my sample.csv may contain arbitrary number of rows.