Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

use python. my code is wrong somewhere. please point it out for me! image text in transcribed
image text in transcribed
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial And Temporal Databases 8th International Symposium Sstd 2003 Santorini Island Greece July 2003 Proceedings Lncs 2750

Authors: Thanasis Hadzilacos ,Yannis Manolopoulos ,John F. Roddick ,Yannis Theodoridis

2003rd Edition

3540405356, 978-3540405351

More Books

Students also viewed these Databases questions