def start():
    mapper = Mapper()
    reducer = Reducer()

    # Produce a list of all the airports in a csv file with the headings 'Airport Code', and 'Null'
    mapper.setInputFile("./inputFiles/PassengerData.csv")
    mapper.setMapFunction(PassengersOnEachFlightUserCode.mapPassengerToFlight)
    reducer.setRedFunction(PassengersOnEachFlightUserCode.redCountPassengers)
    reducer.setOutputFile("./results/NumberOfPassengersOnEachFlight.csv")
    noPassengers = mapper.run()
    reducer.run(noPassengers, 'w')

    print(":: Task 2 complete")
def start():
    mapper = Mapper()
    reducer = Reducer()

    # Produce a list of all the airports in a csv file with the headings 'Airport Code', and 'Null'
    mapper.setInputFile("./inputFiles/PassengerData.csv")
    mapper.setMapFunction(FlightInformationUserCode.mapReOrder)
    reducer.setRedFunction(FlightInformationUserCode.redCalcFlightInfo)
    reducer.setOutputFile(
        "./results/ListOfFlightsWithDurationAndAllPassengers.csv")
    noPassengers = mapper.run()
    reducer.run(noPassengers, 'w')

    print(":: Task 3 complete")
Exemple #3
0
def start():
    mapper = Mapper()
    reducer = Reducer()

    mapper.setInputFile("./inputFiles/AComp_Passenger_data.csv")
    mapper.setMapFunction(StripErrorsUserCode.mapDuplicates)
    reducer.setRedFunction(StripErrorsUserCode.redWrite)
    reducer.setOutputFile("./inputFiles/PassengerData.csv")
    pairs = mapper.run()
    reducer.run(pairs, 'w')

    mapper.setInputFile("./inputFiles/PassengerData.csv")
    mapper.setMapFunction(StripErrorsUserCode.mapSpelling)
    pairs = mapper.run()
    reducer.run(pairs, 'w')
Exemple #4
0
def start():
    mapper = Mapper()
    reducer = Reducer()

    # Produce a list of all the airports in a csv file with the headings 'Airport Code', and 'Null'
    mapper.setInputFile("./inputFiles/Top30_airports_LatLong.csv")
    mapper.setMapFunction(NoOfFlightsFromAirportsUserCode.mapUnusedAirports)
    reducer.setRedFunction(NoOfFlightsFromAirportsUserCode.redUnusedAirports)
    reducer.setOutputFile("./results/Airports.csv")
    unusedAirports = mapper.run()
    reducer.run(unusedAirports, 'w')

    # Produce a list of all the airports used in the passenger data file in a csv file with the headings 'Airport Code', and 'Number of flights from that airport'
    mapper.setInputFile("./inputFiles/PassengerData.csv")
    mapper.setMapFunction(NoOfFlightsFromAirportsUserCode.mapUsedAirports)
    reducer.setRedFunction(NoOfFlightsFromAirportsUserCode.redUsedAirports)
    usedAirports = mapper.run()
    reducer.run(usedAirports, 'a')

    # Combine the two above results to give a list of all flights from each airport, including those that aren't used
    # Heading titles: 'Airport code', 'No. of flights from that airport'
    mapper.setMapFunction(NoOfFlightsFromAirportsUserCode.mapMakePairs)
    mapper.setInputFile("./results/Airports.csv")
    reducer.setOutputFile("./results/NumberOfFlightsFromEachAirport.csv")
    allAirports = mapper.run()
    reducer.setRedFunction(NoOfFlightsFromAirportsUserCode.redCountFlights)
    reducer.run(allAirports, 'w')

    print(":: Task 1 complete")
def start():
    mapper = Mapper()
    reducer = Reducer()

    mapper.setInputFile("./inputFiles/PassengerData.csv")
    mapper.setMapFunction(CalcDistanceUserCode.mapCalcFlightDistances)
    reducer.setRedFunction(CalcDistanceUserCode.redCalcFlightDistance)
    reducer.setOutputFile("./results/FlightDistances.csv")
    flightDistances = mapper.run()
    reducer.run(flightDistances, 'w')

    mapper.setInputFile("./results/FlightDistances.csv")
    mapper.setMapFunction(CalcDistanceUserCode.mapTotalPassengerDistance)
    reducer.setRedFunction(CalcDistanceUserCode.redTotalPassengerDistance)
    reducer.setOutputFile(
        "./results/TotalDistanceTravelledByEachPassenger.csv")
    passengerDistance = mapper.run()
    reducer.run(passengerDistance, 'w')

    mapper.setInputFile("./results/FlightDistances.csv")
    mapper.setMapFunction(CalcDistanceUserCode.mapDistaces)
    reducer.setRedFunction(CalcDistanceUserCode.redDistances)
    reducer.setOutputFile("./results/DistanceOfEachFlight.csv")
    distances = mapper.run()
    reducer.run(distances, 'w')

    print(":: Task 4 complete")