Until next week, study the material provided on Jupter notebooks and solve the following two exercises.
Use the opportunity of solving the exercises in a notebook to familiarize yourself with the workflow of creating and deleting cells, writing markdown, and running code in a notebook. Download the file 03_unit/tasks.ipynb to find a notebook that I prepared for you.
Below, I have pasted some code that reads the contents of the file 03_unit/Stationsliste_20230101.csv line-by-line. (Note, you have to put both the .csv file and this notebook in the same directory, preferably into 03_unit, for the code to work.)
# Open the csv file:withopen('Stationsliste_20230101.csv', encoding='latin-1') as fhand:# Initialize a variable that counts the number of lines count =0# Iterate through all lines in the csv filefor line in fhand: count +=1 line = line.rstrip()# <your code will go here># once you are starting to add your code, you can comment out # the following three lines that produce the current output:print(line)if count >5:break
Your task is to extend this code to ignore the first line, and then populate three lists with data: names, years, elevations. The lists contain the data converted to int and floats for the lists years and elevations. Here is the expected output for the first 5 lines and the list years (note that you will have to extract the years from the complete date):
>>> years
[2021, 2004, 2007, 2007, 1989]
The lists should contain 278 elements each.
Tip: The string methods .split() and .replace(), as well as string slicing, help you achieve that goal.
#02-11: Extracting useful information from the Austrian weather station csv file
Now, use the lists you just computed and the function filter_list you created earlier in exercise #02-09, as well as the python function max() and the list method index() to answer the following questions:
How many stations are located above 2000m?
what is the highest station elevation, and what is the station’s name?