''' Purpose: practice getting organized data into a useful dataset ''' import url import pause # specify data source DATASET_SOURCE = 'http://www.cs.virginia.edu/~cs1112/datasets/csv/best-sellers.csv' # get data for the dataset dataset = url.get_csv_dataset( DATASET_SOURCE ) print( dataset ) pause.enter_when_ready() # determine dataset header header = dataset[ 0 ] print( header ) pause.enter_when_ready() # determine and print books of the dataset books = dataset[ 1 : ] print( books ) pause.enter_when_ready() # determine number of books nbr_books = len( books ) print( nbr_books) pause.enter_when_ready() # print titles of best sellers print( 'Best seller titles' ) for book in books: title, author = book print( title ) pause.enter_when_ready() # print authors of best sellers print( 'Best seller authors' ) for book in books: title, author = book print( author ) pause.enter_when_ready() # another way # determine which column is the title i = header.index( 'Title' ) print( 'Best seller titles' ) for book in books: title = book[ i ] print( title )