''' 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_convert_csv_dataset( link ) # what is dataset? # get the labels for the columns of interest reply = input( 'Enter a column label for the data set: ' ) column1 = reply.strip() reply = input( 'Enter a column label for the data set: ' ) # what happens when you enter different information here? column2 = reply.strip() print() # header specifies column labels header = dataset[ 0 ] # which row does this represent? data = dataset[ 1: ] # which rows does data represent? where is index 1? # scan the column that the user indicated interest in c1 = header.index( column1 ) # what does the index function do? c2 = header.index( column2 ) cells = [] # a list to help us keep track of all the cells for each_row in data: cell = each_row[ c2 ] # what data type is this? what information does cell represent? what data type is this? cells.append( cell ) min_cells = min( cells ) # we have the actual minimum, but we want the column1 information related to min_cells spot = cells.index( min_cells ) # what does spot represent? what does it tell us? row_interested_in = data[ spot ] # get corresponding row from the dataset label = row_interested_in[ c1 ] # get the column1 cell (i.e. at index c1 ) print( "The min", column2, "for the dataset is", min_cells ) print( "It is in the row whose", column1, "value is", label )