So I’m extracting the lines that I want from this larger file using this program:
import csv
name = ['NAMETHEFIRST,' 'NAMEANOTHERNAME ']
data = csv.reader(open('C:\\bigfile.csv'))
with open('C:\\smalldataset.xcl','w') as outf:
csv.writer(outf).writerows(l for l in data if l[0] in name)
The program runs. However I am only getting the line of data from NAMETHEFIRST and I get no data from NAMETHEOTHERNAME written to my small dataset file. This works exactly as I want printing all relevant info from the large data set of the line of data for NAME THE FIRST but i get no information from the second nametheother name written to the smaller file. Why isn’t this working?
This is a list with one string:
This is a list with two strings:
Note the placement of the comma.
Also note that your second string has a space at the end.