''' Purpose: print the contents of a CSV web file ''' # specify data source CSV_WEB_FILE = 'http://www.cs.virginia.edu/~cs1112/datasets/csv/rows_of_stuff.csv' # import local module url to help automate getting contents of a web resource import url # import pause to control execution (not something to be in your code) import pause # get contents of web resource contents = url.get_contents( CSV_WEB_FILE ) # get contents into dataset form dataset = contents.strip() # clean up dataset = dataset.split( '\n' ) # split dataset into a list of rows print( dataset ) # echo dataset to see what we got so far pause.enter_when_ready() nbr_rows = len( dataset ) # determine number of rows of data for i in range( 0, nbr_rows ) : # split each row into its constiuent columns row = dataset[ i ] row = row.strip() # clean up the row row = row.split( ',' ) # split the csv-based rows dataset[ i ] = row # print the dataset for row in dataset : print( row )