''' Purpose: for user-specified dataset, and two user-specified column labels column1 and column2: determines the minimum value min2 in column2 in the dataset determines min_label -- the column1 value whose column2 value equals min2 prints labeled explanatory information about min2 ''' # get ahold of helpful web functions import url # specify base web folder for datasets CSV_REPOSITORY = 'http://www.cs.virginia.edu/~cs1112/datasets/csv/' # get dataset of interest reply = input( 'Enter the name of a data set: ' ) name = reply.strip() link = CSV_REPOSITORY + name dataset = url.get_and_parse_dataset( link ) # get the labels for the columns of interest reply = input( 'Enter a column label for the data set: ' ) column1 = reply.strip() # column1 = column1.capitalize() reply = input( 'Enter a column label for the data set: ' ) column2 = reply.strip() # column2 = column2.capitalize() doesn't work for two words... print() # analyze the dataset for the requested information header = dataset[0] table = dataset[1:] index1 = header.index(column1) index2 = header.index(column2) # Initialize accumulator data_cells = [] for row in table: cell = row[index1] data_cells.append(cell) #print(data_cells) min_index1_value = min(data_cells) print(min_index1_value) # Which index2 value corresponds to the min_index1_value? # Where in data_cells did we find the min_index1_value? r = data_cells.index(min_index1_value) # So r is the row number that contained min_index1_value #print(r) #print(table[r]) row = table[r] # The row of our table containing the min_index1_value index2_cell_value = row[index2] print(index2_cell_value)