Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am working in python 2.7 and I can't seem to get a zscore subfunction to work with my main function. here what i have

I am working in python 2.7 and I can't seem to get a zscore subfunction to work with my main function. here what i have so far grom problem 1. i have to revise or add on to this by adding a z score sub function..

import os from math import sqrt

def process_file(reader): for line in reader: line = line.strip() print line def main(): wd = raw_input("What is the working directory?" ) inf = raw_input("What is the name of the input file?" ) fullpath = os.path.join(wd, inf) input_file = open(fullpath, "r") process_file(input_file) input_file.close() main() image text in transcribed

image text in transcribed

the input file looks like this - NCSIDS_ObsExp

Ashe,1853282.679,1673876.66,1 ,2 Alleghany,1963178.059,1695301.229,0 ,1 Surry,2092564.258,1666785.835,5 ,6 Currituck,3464227.016,1699924.786,1 ,1

2] (20 Points) Define a sub-function called "calculateZscore" that will be called from your main program. This function should have two (2) input parameters: a string representing the full path of the input file and a string representing the full path of the output file. full the fall path of the o Read the input file (i.e. "NCSIDS_ObsExp.txt") and create (i e. write) a new output file that contains all the fields in the input file plus the local z-statistic for each county as a new column. Remember the data should be comma-separated As you read in the input file and process it, you should store the local z-scores in a list variable. This function should have one ( 1 ) output parameter: the list of local z-scores you created. After you create the sub-function "calculateZscore", go back and revise the "main" function so that it utilizes and calls this sub-function. Pass to the function the input and output paths you created in Problem[1 and assign the output of "calculateZscore" (the list of local z-scores) to a new variable in "main" so that you can use it later

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