def read_usernames(filename):
    '''Extracts usernames from the given file, returning a sorted list.

    The file should either be:
        1) A list of usernames, one per line
        2) A CSV file with a 'username' column (specified in its header line)
    '''
    try:
        rows = [r for r in csv.reader(open(filename))]
        try:
            idx = rows[0].index('username')
            unames = [row[idx].lower() for row in rows[1:]]
        except __HOLE__:
            unames = [r[0] for r in rows]
        return sorted(set(unames))
    except IOError, e:
        # File doesn't exist
        return []
dataset/ETHPy150Open everett-wetchler/okcupid/FetchProfiles.py/read_usernames