def getData(wanted_symbol, filename):
    out = []

def checkMatch(line):
    return line.split(',', 1)[0]
with open(filename) as file:
    for symb, lines in groupby(file, checkMatch):
        if symb != wanted_symbol:
            continue
for line in csv.reader(lines):
    out.append([typ(val) for typ, val in zip(castings, line)])
return out
Быстрое извлечение фрагментов строк из большого файла CSV.