So, I'm a rookie at web scrapping and Python in general, and I'm having quite a hard time learning it. I'm trying to get some data from a csv file, but so far I could only split lines and columns. I don't have the slightest idea of how I'm supposed to proceed from now on.

From a certain CSV file, I'm supposed to say which Scandinavian country (Sweden, Norway and Denmark) won the most gold medals in the following categories: curling, skating, skiing and ice hokey, starting from year 2001.

Here's what I've managed to do so far:

import requests
from bs4 import BeautifulSoup

url = "https://sites.google.com/site/dr2fundamentospython/arquivos/Winter_Olympics_Medals.csv"

# Usando requests
csv = requests.get(url).text

lines = csv.splitlines()

for l in range(1, len(lines)):
  columns = lines[l].split(',')

Any comments will be greatly appreciated


CSV is a format meant to machine and human-readable. Most programming languages have support to use CSV's, and Python is certainly one of them.

There is a standard library that would help, you will find it here: https://docs.python.org/3/library/csv.html#module-csv

I would recommend however to install the pandas package, to read the CSV into a structure made for analysis. There is a tutorial here: https://www.datacamp.com/community/tutorials/pandas-read-csv


Not the answer you're looking for? Browse other questions tagged or ask your own question.