Question: why i ' m not getting any output from this path: my _ results, A 0 1 _ Part 1 : result.txt . Technology: Python
why im not getting any output from this path: myresults, APart: result.txt
Technology:
Python without using the MapReduce simulator
Your task is to:
Compute the topnbikes with highest total duration time for their trips.
Complete the function mymain of the Python program.
o Do not modify the name of the function nor the parameters it receives.
o In particular, the function must read the dataset provided in inputfolder and must open
and write the results to outputfile. The number of bikes to output is specified by the
parameter topnbikes. For example, if topnbikes then you must output the
bikes with highest total duration time for their trips.
o You can use the auxiliary function processline which, given one line from a dataset
file, returns a tuple with its content.
o You can also program any other auxiliary functions you might need.
Results:
Output one text line per bikeid Lines must follow decreasing order in highest total duration
time for their trips. Each line must have the following format:
bikeid t totaldurationtimefortheirtrips, totalnumberoftrips
def mymaininputfolder, outputfile, topnbikes:
bikeIdList
bikeIdListUnique set
combineddata
for filepath in glob.iglobinputfolder csv:
with openfilepathr as file:
for row in file:
combineddata.appendprocesslinerow
for cd in combineddata:
bikeIdList.appendcd
for x in bikeIdList:
bikeIdListUnique.addx
biketuplelist
for x in bikeIdListUnique:
totalTripDuration
totalTripNumber
for d in combineddata:
if d x:
totalTripDuration d
totalTripNumber
biketuplelist.appendx totalTripDuration, totalTripNumber
biketuplelist sortedbiketuplelist, keylambda t: t reverseTrue:topnbikes
# Open file for writing to
with openoutputfile, w as file:
# Loop over the list of tuples and write each to the file as a line of text
for x in biketuplelist:
file.writestrxt strx strx
# PYTHON EXECUTION
if namemain:
inputfolder mydataset
outputfile myresultsAPartresulttxt
topnbikes
if lensysargv:
inputfolder sysargv
outputfile sysargv
mymaininputfolder, outputfile, topnbikes
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
