Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Using python complete the function definitions are provided below: Please avoid using any Python facilities/capabilities yet to cover in the course. Please use expressive variable

Using python complete the function definitions are provided below:

Please avoid using any Python facilities/capabilities yet to cover in the course.

Please use expressive variable names.

# YOU ARE NOT TO ALTER ANY GIVEN FILE IN ANY WAY, OR ADD ANYTHING

# ANY FILE OR FOLDER TO ANY GIVEN FOLDER

# ASSUME THESE FOLDERS AND FILES EXIST FOR SUBMISSION

# TESTS ARE NOT PROVIDED THIS WEEK. PAY CLOSE ATTENTION TO

# THE PROMPTS, VISUALLY CHECK FILES YOU CREATE TO MAKE SURE

# THEY ARE IN THE CORRECT OUTPUT FOLDER AND CONTAIN THE TEXT YOU INTENDED TO WRITE.

available_vr_rooms

'''

Create a function called available_vr_rooms that takes one parameter called data_path and returns a tuple.

It will typically be called with a Path object, e.g.: available_vr_rooms(data_path=Path('data', 'vrdata'))

1) RETURNS

- Because this is a utility to be called by another one of your functions, you are not to handle

any exceptions. Just let them be raised as usual and the calling function can handle them

if necessary.

- If no exception is raised, this function will return an empty tuple, or a

tuple of strings.

Then, for every .txt file in the folder (ignore any non-txt files),

2) The vrdata files each contains multiple references to ROOMNAME.

Your function needs to look in each file and

- Take a look at all the room names found in each file so that you can build a

list of room names from across all of the files.

3) If there are no room names, return an empty tuple. Otherwise, return a tuple with

*1* copy of each unique room name you found across all of the files in the specified folder.

'''

# DEFINE AND WRITE YOUR FUNCTION HERE

room_time

'''

Create a function called room_time that takes 2 parameters. One is a string parameter called 'room'.

The other is a Path parameter called data_path. The function returns a tuple.

It will typically be called like this: room_time(data_path=Path('data', 'vrdata'), room='removing key')

Parameter Checking:

- if the room parameter is not a string or refers to a room name that does not exist in the data,

return an empty tuple and print this message:

Room "BLAH" does not exist in the VR data (where BLAH is the room requested)

- if data_path is not a valid path, return an empty tuple and this message:

"BLAH" is not a valid folder path

How to find this information:

- The data files will have a .txt extension...only read these files and ignore files with other extensions.

- In each data file in the data path, there will be several room records (each separated by a bunch of dashes).

- In each of these room records, you will find a room name and a room duration. The duration is how long the user spent in this virtual room. Collect all of these durations for each room record with the target room name.

- The general approach is this: For each file, get the room records. For each room record, if it has the target room name, find the line on which the duration is shown. From that line, get the room duration and the move to the next room record.

What to Return:

- you are returning a tuple containing all of the room durations from all room records across all data files in the

data path from that refer to the target room.

Announcing the file you're working on:

- print "Processing BLAH" where BLAH is just the file name of the path you are currently processing

'''

Update files:

data is a folder that contains 2 different folders one called room and the other vrdata, the vrdata folder consists of multiple txt files and few non txt files in the format:(101_.txt, 102_.txt)...

---------------------------------------------------- USERNUMBER: 101 CONFIGFILE: cogs DATABASEPOSITION: DATABASE_NAME1 DATABASE: X1.mdb STARTTIME: 0415145:16:25 PM ------------------------------------------------------------ PREVIOUSROOM: -1 ROOMNUMBER: 106 ROOMNAME: story CLICKED OBJECT150 (StartPortal): PORTAL TO ROOM150 ROOMDURATION: 26657 ------------------------------------------------------------ ------------------------------------------------------------ PREVIOUSROOM: 106 ROOMNUMBER: 150 ROOMNAME: beginning CLICKED OBJECT108 (NewObjectName): PORTAL TO ROOM108 ROOMDURATION: 210297 ------------------------------------------------------------ ------------------------------------------------------------ PREVIOUSROOM: 146 ROOMNUMBER: 114 ROOMNAME: outside office door CLICKED OBJECT115 (enter office): PORTAL TO ROOM115 ROOMDURATION: 4094 ------------------------------------------------------------ ------------------------------------------------------------

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_2

Step: 3

blur-text-image_3

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

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students explore these related Databases questions