Right now my code adds the text from the required rows from 2 different csv files into one list:
import csv
res = []
with open('csvexample.csv') as f, open('csvexample1.csv') as a:
reader=csv.reader(f)
reader1=csv.reader(a)
next(reader)
next(reader1)
for row in zip(reader, reader1):
res.extend([row[0][0], row[1][1]])
print(res)
Let's say csvexample.csv looks like this:
ID Text
1 'good morning'
2 'good afternoon'
3 'good evening'
and csvexample1.csv looks like this:
Day Month
14 'Feb'
21 'Mar'
31 'May'
10
The outcome is as follows:
['1', 'feb', '2', 'mar', '3', '']
However, I want it to print out 'May' for the csvexample1.csv file was well, and just ignore the empty cells. What do I need to change about the current code to make sure that happens?
row[0][0]??) that distract from the question. Post something that you have run yourself and that shows the problem. Otherwise you are sticking us with it.