# Employees3 Example # Source code file: employees1.py # Input file: employees.txt # Compute the maximum of the women's salaries. # Fields in employees.txt input file: # Name,Gender,Age,City,Salary # Note that these fields are shown in the # first line of the input file. This line # must be read and thrown away before # processing the data lines. fin = open("employees.txt", "r") # Read and throw away first line: fin.readline( ) # Read and process second line from file line = fin.readline( ) fields = line.split(",") name = fields[0].strip( ) gender = fields[1].strip( ) age = int(fields[2].strip( )) city = fields[3].strip( ) salary = float(fields[4].strip( )) if gender == "F": maximum = salary # Process lines until end of file while line != "": fields = line.split(",") name = fields[0].strip( ) gender = fields[1].strip( ) age = int(fields[2].strip( )) city = fields[3].strip( ) salary = float(fields[4].strip( )) if gender == "F": maximum = max(maximum, salary) line = fin.readline( ) print("Maximum of women's salaries:", maximum) fin.close( ) # Output: # Maximum of women's salaries: 85000