def get_ranked_sites(location, as_list=False):
    """
    returns a dictionary of site rank from the
    top-1m.csv file located at <location>
    <as_list> (True)   returns rank ordered list
              (False)  returns dict[url] = rank
    """
    with open(location, 'r') as f:
        sites = ['http://' + x.split(',')[1]
                 for x in f.read().strip().split('\n')]
    if as_list:
        return sites
    site_rank = dict()
    for i in range(len(sites)):
        site_rank[sites[i]] = i + 1
    return site_rank