def loadData(analyzer, tupleFiles): connectionsFile = cf.data_dir + tupleFiles[0] connections_file = csv.DictReader(open(connectionsFile, encoding="utf-8-sig"), delimiter=",") countriesFile = cf.data_dir + tupleFiles[1] countries_file = csv.DictReader(open(countriesFile, encoding="utf-8"), delimiter=",") landing_pointsFile = cf.data_dir + tupleFiles[2] landing_point_file = csv.DictReader(open(landing_pointsFile, encoding="utf-8"), delimiter=",") for station in connections_file: model.addConnection(analyzer, station) model.createVertexEdge(analyzer, station) model.addConnectionToMap(analyzer) for country in countries_file: model.addCountry(analyzer, country) model.addCountryToMap(analyzer) for landingPoint in landing_point_file: model.addLandingPoint(analyzer, landingPoint) model.addLandingPointToMap(analyzer) model.addLandingPointToIDMap(analyzer) model.connectToCapital(analyzer) return analyzer
def loadConnections(analyzer): """ Carga las conexiones entre puntos """ file = cf.data_dir + 'connections.csv' input_file = csv.DictReader(open(file, encoding='utf-8'), delimiter=",") for connection in input_file: model.addConnection(analyzer, connection)
def loadConnection(analyzer, file): file = cf.data_dir + file input_file = csv.DictReader(open(file, encoding="utf-8"), delimiter=",") for connection in input_file: model.addConnection(analyzer, connection) model.addConnection_directed(analyzer, connection) model.addSameOrigin(analyzer) model.addSameOrigin_directed(analyzer) return analyzer
def loadServices(analyzer): """ Carga los datos de los archivos CSV en el modelo. Se crea un arco entre cada par de estaciones que pertenecen al mismo servicio y van en el mismo sentido. addRouteConnection crea conexiones entre diferentes rutas servidas en una misma estación. """ """ delta_time = -1.0 delta_memory = -1.0 tracemalloc.start() start_time = getTime() start_memory = getMemory() """ servicefile = 'connections.csv' servicesfile = cf.data_dir + servicefile input_file = csv.DictReader(open(servicesfile, encoding="utf-8"), delimiter=",") for line in input_file: model.addLanding(analyzer, line) servicefile = 'landing_points.csv' servicesfile = cf.data_dir + servicefile input_file = csv.DictReader(open(servicesfile, encoding="utf-8"), delimiter=",") lastservice = None for line in input_file: model.addInfo(analyzer, line) servicefile = 'countries.csv' servicesfile = cf.data_dir + servicefile input_file = csv.DictReader(open(servicesfile, encoding="utf-8"), delimiter=",") lastservice = None for line in input_file: model.addCountry(analyzer, line) print("1") model.addConnection(analyzer) print('2') model.addCapital(analyzer) print('3') """ stop_memory = getMemory() stop_time = getTime() tracemalloc.stop() delta_time = stop_time - start_time delta_memory = deltaMemory(start_memory, stop_memory) return (analyzer,delta_time, delta_memory)""" return analyzer
def loadConnections(analyzer, landingPointsFile, connectionsFile, countriesFile): delta_time = -1.0 delta_memory = -1.0 tracemalloc.start() start_time = getTime() start_memory = getMemory() landingPointsList = lt.newList('ARRAY_LIST') landingPointsFile = cf.data_dir + landingPointsFile lpFile = csv.DictReader(open(landingPointsFile, encoding="utf-8"), delimiter=",") for lp in lpFile: lt.addLast(landingPointsList, lp) # Por cada landing point en el archivo de entrada, se llama a la función en el modelo model.addLandingPoint(analyzer, lp) model.addCountriesCodes(analyzer, lp) countriesList = lt.newList('ARRAY_LIST') countriesFile = cf.data_dir + countriesFile cntFile = csv.DictReader(open(countriesFile, encoding="utf-8"), delimiter=",") for ctry in cntFile: lt.addLast(countriesList, ctry) # Por cada país en el archivo de entrada, se llama a la función en el modelo model.loadCountry(analyzer, ctry) connectionsFile = cf.data_dir + connectionsFile cnnFile = csv.DictReader(open(connectionsFile, encoding="utf-8-sig"), delimiter=",") for cnn in cnnFile: # Por cada conexión en el archivo de entrada, se llama a la función en el modelo model.addConnection(analyzer, cnn) model.addArchConnections(analyzer, cnn) # Se crean las conexiónes entre los vertices de cada landing point y entre estos y el vertice de la capital model.addPointConnections(analyzer) stop_memory = getMemory() stop_time = getTime() tracemalloc.stop() delta_time = stop_time - start_time delta_memory = deltaMemory(start_memory, stop_memory) return analyzer, lt.firstElement(landingPointsList), lt.firstElement( countriesList), delta_time, delta_memory
def loadConnections(analyzer): """ Se crea un arco entre cada par de vertices que pertenecen al mismo landing_point y van en el mismo sentido. addRouteConnection crea conexiones entre diferentes cables servidas en un mismo landing_point. """ servicesfile = cf.data_dir + 'connections.csv' input_file = csv.DictReader(open(servicesfile, encoding="utf-8"), delimiter=",") for i in input_file: origen = i['\ufefforigin'] destino = i['destination'] longitud = i['cable_length'] model.addConnection(analyzer, origen, destino, longitud, i)
def loadServices(analyzer, LPfile, connectionsfile): """ Carga los datos de los archivos CSV en el modelo. Se crea un arco entre cada par de estaciones que pertenecen al mismo servicio y van en el mismo sentido. addRouteConnection crea conexiones entre diferentes rutas servidas en una misma estación. """ LPfile = cf.data_dir + LPfile LPDict = csv.DictReader(open(LPfile, encoding="utf-8"), delimiter=",") connectionsfile = cf.data_dir + connectionsfile connectionsDict = csv.DictReader(open(connectionsfile, encoding="utf-8"), delimiter=",") for point in LPDict: model.addLP(analyzer, point) for cable in connectionsDict: model.addConnection(analyzer, cable) return analyzer
def loadInfo(structure): countries_count = 0 last_country = None countriesFile = cf.data_dir + 'countries.csv' countriesData = csv.DictReader(open(countriesFile, encoding="utf-8"), delimiter=",") for country in countriesData: structure = model.addCountry(country, structure) countries_count += 1 if countries_count == 238: last_country = country countries_info = {'last': last_country, 'count': countries_count} lpoints_count = 0 first_lpoint = None lpointsFile = cf.data_dir + 'landing_points.csv' lpointsData = csv.DictReader(open(lpointsFile, encoding="utf-8"), delimiter=",") for lpoint in lpointsData: structure = model.addLpoint(lpoint, structure) lpoints_count += 1 if lpoints_count == 1: first_lpoint = lpoint lpoints_info = {'first': first_lpoint, 'count': lpoints_count} connections_count = 0 connectionsFile = cf.data_dir + 'connections.csv' connectionsData = csv.DictReader(open(connectionsFile, encoding="utf-8-sig"), delimiter=",") for connection in connectionsData: structure = model.addConnection(connection, structure) connections_count += 1 connections_info = connections_count return [structure, [countries_info, lpoints_info, connections_info]]
def loadConnections(cont, connectionsfile): cfile = cf.data_dir + connectionsfile input_file = csv.DictReader(open(cfile, encoding="utf-8"), delimiter=",") for i in input_file: model.addConnection(cont, i)
def loadConnections(catalog): connectionsfile = cf.data_dir + "connections.csv" inputfile = csv.DictReader(open(connectionsfile, encoding='utf-8-sig'), delimiter=",") for connection in inputfile: model.addConnection(catalog, connection) model.sameLPcables(catalog)