Skip to content
    FinalProjectWk5@reyesrob29
    .gitignore
    data.csv
    generated-icon.png
    main.py
    Packager files
    poetry.lock
    pyproject.toml
    Config files
    .replit
    replit.nix
    import csv
    import matplotlib.pyplot as plt

    def generate_population_dictionary_from_csv(filename):

    output = {}

    with open(filename, 'r') as csvfile:
    reader = csv.DictReader(csvfile)
    for line in reader:
    continent = line['continent']
    year = int(line['year'])
    population = int(line['population'])

    if continent not in output:
    output[continent] = {'population': [], 'years': []}

    output[continent]['population'].append(population)
    output[continent]['years'].append(year)

    return output

    def generate_population_plots_from_dictionary(population_dictonary):

    for continent in population_dictonary:
    years = population_dictonary[continent]['years']
    population = population_dictonary[continent]['population']
    plt.plot(years, population, label=continent, marker="o")

    plt.title("Internet Population per continent", weight='bold', fontsize=20, color= 'blue')
    plt.xlabel("Year", weight='bold', style='italic', fontsize=12)
    plt.ylabel("Internet users (in billion users)", weight='bold', style='italic', fontsize=12)
    plt.grid(True)
    plt.tight_layout()
    plt.legend()
    plt.show()


    filename = 'data.csv'

    population_per_continent = generate_population_dictionary_from_csv(filename)
    generate_population_plots_from_dictionary(population_per_continent)