Web scraping is more an art than a science, IMHO. Not sure Mathematica is a good tool to accomplish your goal. It is not a very good tool to do data munging, cleaning.
In your results, you may want to do some data review. I ran your notebook on OS X 10.10.5 with Mathematica 11.0 and in the resulting spreadsheet the following problems seem to have occurred:
Row 523
Row 829
Row 853
919 total rows including header row 1
which implies 919 medals awarded, however if I just use copy and paste on the following URL: http://www.nbcolympics.com/medals I end up with a total medal count of 975 (notes: the resulting copy and paste yielded an error on row 26 for country Ukraine, the columns shifted left one column which I fixed manually)
Below are a set of steps in Excel only to get you to a spreadsheet that has correct number of awarded medals per event (note, I am off by 1 medal and my results need testing). The steps below deal with ties and related events in some events. My results at the intermediate step where I stopped are off by 1 metal in total count from the above count of 975.
These steps are all simple excel operations, result is spreadsheet of values, each row contains column for medal count for 1st, 2nd and 3rd.
To continue any further you will need to move to more advanced Excel Visual Basic code or move to a more powerful tool to find where the one metal was off, to pivot the data and continue to make it more tidy. However, it will become more difficult to parse programmatically as in few steps the athlete names are not parseable by ties, countries or team members.
Good hunting!
Data munging sucks then we die.... ;-)
Steps to create the attached spreadsheet, done on OS X 10.10.5 Excel for Mac 2011 V14.6.6.
Highlight results from web page:
https://www.rio2016.com/en/medal-count-sports
copy and paste to Excel
Delete 1st four rows
insert blank column in front of left most column
insert following formula in cell A1:
=IF(EXACT(C1,""),B1,"")
copy and paste this formula down to remainder of column A
highlight entire spreadsheet and copy
create new blank spreadsheet and paste values
insert new column to the left of column A
in cell A1 enter following formula:
=IF(EXACT(B1,C1),B1,INDIRECT(ADDRESS(ROW()-1,COLUMN())))
copy and paste this formula down to remainder of column A
highlight entire spreadsheet and copy
create new blank spreadsheet and paste values
delete column B in new spreadsheet
hightlight all cells
sort ascending by column C
scroll down and delete bottom rows that contain only values in column A and B
highlight entire spreadsheet
sort ascending by column A
highlight all rows with data and copy
scroll down to first empty row and paste
scroll down again to first empty row and paste
highlight all cells
sort ascending by column A and add second sort ascending by column B
insert column before column C
in cell C1 insert formula:
=LEN(D517)/3
copy cell C1 down to all rows in column C with data
insert column before column E
in cell D1 insert formula:
=LEN(G1)/3
copy cell D1 down to all rows in column D with data
insert column before column F
in cell E1 insert formula:
=LEN(J1)/3
copy cell E1 down to all rows in column E with data
highlight entire spreadsheet and copy
create new blank spreadsheet and paste values
highlight all cells
under data function, select delete duplicates, select ALL columns
create a sum for column C
create a sum for column D
create a sum for column E
These are Gold, Silver and Bronze counts
sum these three values to get 974
This number is 1 medal less than what was found by the count from scraping web page:
http://www.nbcolympics.com/medals
Attachments: