''' Purpose: print the contents of a CSV web file ''' # use local module url to help automate getting contents of a web resource import url # define the base folder for course csv datasets CSV_WEB_FOLDER = "http://www.cs.virginia.edu/~cs1112/datasets/csv/" # specify data source reply = input( "Enter name of dataset: " ) # clean up the reply to get file name file_name = reply.strip() # get url link for dataset link = CSV_WEB_FOLDER + file_name # get web resource dataset as rows of strings dataset = url.get_raw_dataset( link ) # this is a function that # does everything from get_a_dataset.py for you! So it gets a webpage # csv text and makes it into a dataset (list of lists) for you! # echo dataset row by row for row in dataset : print( row ) print() # get web resource dataset as rows of values dataset = url.get_dataset( link ) # If you need to read a dataset, # this one will make any numeric strings into numbers too and # string boolean values into correct booleans so # that you can work with them (so that types have meanings) # echo dataset row by row for row in dataset : print( row )