import csv


def page_titles_to_ids(titles_set, page_table_filename):
    """
    Parse data from the Wikipedia page database table to get page IDs for
    the given set of page titles.
    """
    mapping = {}
    with open(page_table_filename, encoding='utf8') as page_file:
        reader = csv.reader(page_file)
        for line in reader:
            id, namespace, title = int(line[0]), line[1], line[2]
            if namespace == '0' and title in titles_set:
                mapping[title] = id
    return mapping