Search for subsets within a 250k line text dataset The code below works pretty well - it takes about 4 seconds (this seems too slow for me) to find a group that's located in the tail area of the text file I'm searching. The text file has ≃ 250,000 lines with 20 elements per line. I cut my teeth on other programming languages and picked up Python just for this current project I'm working on, so I really am a neophyte when it comes to python efficiency.

with open(file) as infile:
    datadictionary = csv.DictReader(infile, dialect='excel-tab', quoting=csv.QUOTE_NONE)
    for key, group in itertools.groupby(datadictionary, key=lambda x:x[patient_number_field_header] == patient_id):
        if key:
            super_list = group
            break



'patient_id' is a string of digits
file is a text file


I'm wondering what you think - how can I make this more efficient? Am I "doing it wrong"?
I'm assuming your code does some background processing, because otherwise the patient data would be stored in a database, not in a text file. In that scenario, 4 seconds is probably ok.

Instead of grouping the records, you could simply filter them. That saves two lines of code, but will probably not be much faster.