i have CSV file as the following:
aa , a1, 1, bb, b1, 11, cc, c1, 111
aa2 , a2, 2, bb2, b2, 22, cc2, c2, 222
aa3 , a3, 3, bb3, b3, 33, cc3, c3, 333
and I need to take the first three content and store it in array like:
aa , a1, 1, bb, b1, 11, cc, c1, 111
will become into ['aa a1 1', 'bb b1 11', 'cc c1 111']
and this my code:
import csv
with open('Test.csv') as csv_file:
csv_reader = csv.reader(csv_file)
rows = list(csv_reader)
lines= len(list(rows))
for line in range(lines):
i=0
j=1
k=2
for l in range(len(list(rows[line]))):
t=[]
t.append(rows[line][i]+rows[line][j]+rows[line][k])
print(t[0:])
i+=3
j+=3
k+=3