import csv


def read_populi_csv(csvfilename):
    """ Return user data from student populi csv export """
    # populi csv export fields :
    #   "Student ID",Prefix,"First Name","Preferred Name",
    #   "Middle Name","Last Name","Former Name",Email,
    #   Street,City,State,ZIP,Country,Phone,Type,"Receives Mail"
    # If there is a 'Preferred Name', use that as the first,
    # then let 'name' be 'first last'. Ignore (prefix, middle, former)
    # Return fields for (username,name,email,password)
    result = []
    for row in csv.DictReader(open(csvfilename)):
        if row['Type']=='faculty': continue
        name = (row['Preferred Name'] or row['First Name']) + \
               ' ' + row['Last Name']
        email = row['Email']
        result.append({'name':name, 'email':email})
    return result