import os
os.chdir("/home/guerzhoy/Desktop/c4m")







def get_med_winners(filename, year):
    '''(str, int) -> list
    Return the list of the names of the winners
    in physilogy/medicine in year year. The year must be between 1900  and 2013
    The information about all the winners
    is in file filanmes, in CSV format
    '''
    
    f = open(filename)
    f.readline()
    f.readline()
    
    line = f.readline()
    cur_year = int(line.split(',')[0])
    
    res = []
    
    #Keep reading the file line by line until we get
    #to the year that we're looking for
    while cur_year != year:
        line = f.readline()
        if line.split(',')[0] != "":
            cur_year = int(line.split(',')[0])
            
    #cur_year == year
    
    #Keep reading until we encounter information from the 
    #the next year, and stroing the winners in a list
    while cur_year == year:
        name = line.split(",")[3]
        if name != "None" and name != "":
            res.append(name)
        
        line = f.readline()
        if line.split(',')[0] != "":
            cur_year = int(line.split(',')[0])
    
    return res
    
    
    
get_med_winners("med_nobel.csv", 1947) == ['Carl Ferdinand Cori', 'Gerty Cori', 'Bernardo Houssay']

get_med_winners("med_nobel.csv", 1946) == []

get_med_winners("med_nobel.csv", 1940) == []

get_med_winners("med_nobel.csv", 1919) == ["Jules Bordet"]



