I have a csv file like=>
apple, 23, 45
abricot, 45 12
grape, 123 985
apple, 18, 450
I would like to get row thanks to identifier, for instance get from apple row.. here's my code:
import csv
import re
exampleFile=open('test-csvred.csv')
exampleReader = csv.reader(exampleFile)
for row in exampleReader:
a=str(row)
print ('Row #' + str(exampleReader.line_num)+' ' +a)
t=re.match("apple(.*)",a).group(1)
the code gives me=> NoneType' object has no attribute 'group' I don't really know what is my mistake... thanks in advance
re.matchonly searches for a match at the beginning of the string. Tryre.search.