import csv


def get_pmids_with_genes_in_timeframe(genes_by_pmid, pmid_dates_path):
    """Return PMIDs in genes_by_pmid that were published in a timeframe

    The timeframe is implied by data in the file at `pmid_dates_path`.
    """
    pmids = []

    # This file has no headers so here's an example instead:
    # 2021 34185482
    with open(pmid_dates_path) as fd:
        rd = csv.reader(fd, delimiter='\t')
        for row in rd:
            if row[0][0] == '#':
                continue
            pmid = str(row[1])
            if pmid in genes_by_pmid:
                pmids.append((pmid))

    return pmids