Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(This post is needing help for the problem number 2 . ) I posted a problem (problem 1) earlier that is related to this one.

(This post is needing help for the problem number 2 . ) I posted a problem (problem 1) earlier that is related to this one. Please code it using Python language and put comments as many as possible to help me understand how how it works.

1. Here's the problem number 1:Write a program that reads the provided file station.csvimage text in transcribed text file for reading. It then scans the file for lines where the "DrainageAreaMeasure/MeasureValue" column IS NOT EMPTY, and writes those lines out to output file stations-filtered.csv file. Submit your source code and the filtered file. (station.csv file contains data with comma in the double quotes. Use this file, station_cleaned.csvimage text in transcribed for this problem.) ***I think I was able to figure out the answer of this problem (see code below), but I'm not sure if it is correct. You can tell!!

#My code on problem 1 csv_file = open("stations_cleaned (3).csv", "r")

writefile = open("stations-filtered.csv", "w")

line=csv_file.readline()

while line: line2 = line.split(",") if line2[7] !="": writefile.write(line) print(line) line = csv_file.readline()

Now, here's the problem number 2.

Write a program that reads in the file stations-filtered.csv and computes the average of the "DrainageAreaMeasure/MeasureValue" column and writes it to output file drainage-area-avg.txt.

Here's is the screenshot of the cvs file image text in transcribed

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

More Books

Students also viewed these Databases questions