private void Load() { var watch = Stopwatch.StartNew(); Console.WriteLine(this + "Loading all the necessary data..."); Console.WriteLine(this + "Urban routes only:" + _urbanOnly); _baseDirectoryPath = Directory .GetParent(Directory.GetParent(Directory.GetParent(Environment.CurrentDirectory).FullName).FullName) .FullName; var stopsPath = Path.Combine(_baseDirectoryPath, @"Data Files\stops.txt"); //files from google transit (GTFS file) var routesPath = Path.Combine(_baseDirectoryPath, @"Data Files\routes.txt"); //files from google transit (GTFS file) var demandsPath = Path.Combine(_baseDirectoryPath, @"Data Files\demands.csv"); var stopTimesPath = Path.Combine(_baseDirectoryPath, @"Data Files\stop_times.txt"); // files from google transit (GTFS file) string tripsPath = Path.Combine(_baseDirectoryPath, @"Data Files\trips.txt"); var tripStopsPath = Path.Combine(_baseDirectoryPath, @"Data Files\trip_stops.txt"); //file generated from stop_times.txt and stop.txt var routesData = GenerateListData(routesPath); LoadRoutes(routesData); var tripsData = GenerateListData(tripsPath); LoadTrips(tripsData); var stopsData = GenerateListData(stopsPath); LoadStops(stopsData); var demandsData = GenerateListData(demandsPath); var stopTimesDataList = GenerateListData(stopTimesPath); FileDataExporter dataExporter = new FileDataExporter(); if (!File.Exists(tripStopsPath) ) //if the file doesn't exists, generate the dictionary required to sort the stops in ascending order then export to txt, then reads from the txt the next time the program is executed (to save computational time) { var tripsStopTupleDictionary = GenerateTripStopTuplesDictionary(stopTimesDataList); dataExporter.ExportTripStops(tripsStopTupleDictionary, tripStopsPath); } FileDataReader fdr = new FileDataReader(); var tripsStopData = fdr.ImportData(tripStopsPath, ',', true); LoadStopsIntoTrips(tripsStopData); LoadTripStartTimes(tripsStopData); AssignUrbanStops(); //dataExporter.ExportStops(Stops, Path.Combine(Environment.CurrentDirectory, @"stops.txt")); //dataExporter.ExportTrips(Routes, Path.Combine(Environment.CurrentDirectory, @"trips.txt")); //dataExporter.ExportTripStopSequence(Routes, Path.Combine(Environment.CurrentDirectory, @"trip_stops.txt")); //dataExporter.ExportTripStartTimes(Routes, Path.Combine(Environment.CurrentDirectory, @"trip_start_times.txt")); if (_urbanOnly) { Routes = Routes.FindAll(r => r.UrbanRoute); // only urban routes Trips = Trips.FindAll(t => t.Route.UrbanRoute == true); // only urban trips Stops = Stops.FindAll(s => s.IsUrban); //only urban stops } LoadStopDemands(demandsData); RemoveDuplicateTrips(); watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; Console.WriteLine(this + "All the necessary data was successfully generated in " + elapsedMs * 0.001 + " seconds."); string str; str = _urbanOnly ? "Urban " : ""; Console.WriteLine(this + "Total of " + str + "Routes:" + Routes.Count); Console.WriteLine(this + "Total of " + str + "Route Trips:" + Routes.Sum(r => r.Trips.Count)); Console.WriteLine(this + "Total of " + str + "Stops:" + Stops.Count); }