Question: use python. my code is wrong somewhere. please point it out for me! You should be able to look at the data in NorCal- 1880-2018.csv


You should be able to look at the data in NorCal- 1880-2018.csv your favorite text editor. Here are the first lines of that file. The first five lines are a header that your program should read but ignore. 38.5 deg N, 121.7 deg E Temperature An Units: Degrees Celsius Base Period: 1981-2010 Missing: -9999 Year, Value 1880,-1.56 1881,-0.08 1882,-0.30 Start a new program called read_temp_file.py from your previous program. Add code to read and ignore the first five lines. Your program will then loop over the remaining lines of the file. In the block under the loop that reads the file, use the strip() string method to remove the newline character after each line of input. Use the split() string method to split on the comma to extract the year and the temperature into variables. The temperature should be changed to a floating point number. To test your code, add a print statement to print out the year and temperature. They will be separated by a space instead of the original comma. The last 5 lines of your printed outout should look exactly like this: They will be separated by a space instead of the original comma. The last 5 lines of your printed output should look exactly like this: 2014 -0.06 2015 -0.40 2016 0.48 2017 2.63 2018 0.18 while True: inp=input("Temperature anomaly filename: ") try: #check valid input or not ip=open(inp) print("Analyzing "+inp) break except : print("Could not open "+inp) #again reading input #exiting the while loop #ignore the first five lines for i in range (5): #ignore 5 line 0 1 2 3 4 ip.readline() for line in ip: line=line.strip() year, value=(line.split(',') print (year,value)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
