Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part V: Fetch Information (20 points) In this part we will generalize the results of the previous part to files that contain information other than

image text in transcribed
Part V: Fetch Information (20 points) In this part we will generalize the results of the previous part to files that contain information other than course enrollment data. The first line of the file will contain a comma-separated list of strings that define the format of the file. Some examples e Car data: Make, Model, Year e CPU data: Manufacturer, Model, NumCores, ClockSpeed House data: Town, Year, Price, NumRooms, Taxes Write a function fetch.value ) that takes the following arguments, in this order: 1. filename: The name of a file the function will read data from. All fields in the file will be separated by commas. You may assume that the file is always validly formatted. 2. selected.field: The name of the field from which we are reading values. 3. searched field: The name of the field we are using to search the data. 4. searched.value: The value of the searched.field that we are trying to match To understand the meaning of these arguments, suppose the function were called on CPU data (with field:s Manufacturer, Model, NumCores, ClockSpeed) with the following arguments fetch value('cpu.txt', 'Manufacturer', 'ClockSpeed, 3. This function call indicates that we want a st of CPU manufacturers whose CPU's ClockSpeed field has a valuc of 3'. (Duplicated val- ues are expected, and the number of copies of a selected value must equal the number of lines that match the search.value. Do not sort the returned list.) Note that ALL values in the file are treated as strings, even values we would normally treat as nur merica More generally speaking, the function reads from the given file and finds lines where the value in the searched.field "column" matches the searched.value function argument. When such a line is found, the function appends the corresponding value of selected.field column into the returned list

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

101 Database Exercises Text Workbook

Authors: McGraw-Hill

2nd Edition

0028007484, 978-0028007489

More Books

Students also viewed these Databases questions

Question

If the curve y = f(x), a Answered: 1 week ago

Answered: 1 week ago

Question

In Problems 1968, solve each equation, if possible. 2 + 4 y = 3

Answered: 1 week ago

Question

Differentiate the function. r(z) = 2-8 - 21/2 r'(z) =

Answered: 1 week ago