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
示例#2
0
def loadConnections(analyzer, connections_file):

    connections_file = cf.data_dir + connections_file
    input_file = csv.DictReader(open(connections_file, encoding='utf-8-sig'), delimiter=',')
    for connection in input_file:
        model.addLandingPoint(analyzer, connection)
        model.addLandingPointNormal(analyzer,connection)
    return analyzer
示例#3
0
def loadLandingPoints(analyzer):
    """
    Carga los puntos de llegada
    """
    file = cf.data_dir + 'landing_points.csv'
    input_file = csv.DictReader(open(file, encoding='utf-8'), delimiter=",")
    for landing in input_file:
        model.addLandingPoint(analyzer, landing)
def loadLandingPoints(analyzer, file):

    file = cf.data_dir + file
    input_file = csv.DictReader(open(file, encoding="utf-8"), delimiter=",")

    for landing_point in input_file:
        model.addLandingPoint(analyzer, landing_point)
    return analyzer
def loadLandingPoints(catalog):
    landingpointsfile = cf.data_dir + "landing_points.csv"
    inputfile = csv.DictReader(open(landingpointsfile, encoding='utf-8'), delimiter=",")
    i = 0
    firstlp = None
    for landingpoint in inputfile:
        model.addLandingPoint(catalog, landingpoint)
        if i == 0:
            firstlp = landingpoint
            i += 1
    return firstlp
示例#6
0
def loadLandingPoints(analyzer, servicesfile):
    """
    Carga los libros del archivo.  Por cada libro se indica al
    modelo que debe adicionarlo al catalogo.
    """
    videosfile = cf.data_dir + servicesfile
    input_file = csv.DictReader(open(videosfile, encoding='utf-8'))

    for landingPoint in input_file:
        model.addLandingPoint(analyzer, landingPoint)
    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
示例#8
0
def loadData(analyzer):
    delta_time = -1.0
    delta_memory = -1.0

    tracemalloc.start()
    start_time = getTime()
    start_memory = getMemory()

    songfile1 = cf.data_dir + 'PrepData/connections.csv'
    input_file1 = csv.DictReader(open(songfile1, encoding='utf-8-sig'))
    songfile2 = cf.data_dir + 'PrepData/countries.csv'
    input_file2 = csv.DictReader(open(songfile2, encoding='utf-8'))
    songfile3 = cf.data_dir + 'PrepData/landing_points.csv'
    input_file3 = csv.DictReader(open(songfile3, encoding='utf-8'))
    i = 1
    for value in input_file2:
        model.addCountry(analyzer, value)
        if i == 236:
            country = model.selectResult(value, 'country')
        i += 1
    i = 1
    for value in input_file3:
        model.addLandingPoint(analyzer, value)
        if i == 1:
            landingpoint = model.selectResult(value, 'landingpoint')
            i += 1

    for value in input_file1:
        model.addPointConnection(analyzer, value)

    model.addLandingPointConnections(analyzer)
    model.addCountryConnections(analyzer)

    stop_memory = getMemory()
    stop_time = getTime()
    tracemalloc.stop()

    delta_time = stop_time - start_time
    delta_memory = deltaMemory(start_memory, stop_memory)

    return ((country, landingpoint), (delta_time, delta_memory))
def loadData(analyzer, pointFile, connectFile, countryFile):
    pointFile = cf.data_dir + pointFile
    connectFile = cf.data_dir + connectFile
    countryFile = cf.data_dir + countryFile

    input_file1 = csv.DictReader(open(pointFile, encoding="utf-8"),
                                 delimiter=",")
    for point in input_file1:
        model.addLandingPoint(analyzer, point)

    input_file2 = csv.DictReader(open(connectFile, encoding="utf-8"),
                                 delimiter=",")
    for cable in input_file2:
        model.addCable(analyzer, cable)

    input_file3 = csv.DictReader(open(countryFile, encoding="utf-8"),
                                 delimiter=",")
    contador = 0
    for pais in input_file3:
        model.addPais(analyzer, pais)
        contador += 1
    print(f'Se cargaron {contador} países')

    return analyzer
示例#10
0
def cargar(analyzer):
    
    landingpointsfile = cf.data_dir + "landing_points.csv"
    input_file = csv.DictReader(open(landingpointsfile, encoding="utf-8"),
                                delimiter=",")
    for point in input_file:
        model.addLandingPoint(analyzer,point)


    connectionsfile = cf.data_dir + "connections.csv"
    input_file = csv.DictReader(open(connectionsfile, encoding="utf-8"),delimiter=",")
    for connection in input_file:
        model.addLP_cable(analyzer, connection)
 
    countriesfile = cf.data_dir + "countries.csv"
    input_file = csv.DictReader(open(countriesfile, encoding="utf-8"),
                                delimiter=",")
    for country in input_file:
        model.addCountry(analyzer,country)

    countriesfile2 = cf.data_dir + "countries.csv"
    input_file = csv.DictReader(open(countriesfile2, encoding="utf-8"),
                                delimiter=",")
    for country2 in input_file:
        model.addCapital_V_E(analyzer,country2)
    
    model.edges_same_lp(analyzer)
    
  
    
    num_lps = mp.size(analyzer["landing_points"])
    num_conexiones = gr.numEdges(analyzer["connections_distance"])
    num_paises = mp.size(analyzer["countries"])

  
    return num_lps,num_conexiones,num_paises
示例#11
0
def loadData(analyzer, landingFile, connectionsFile, countriesFile):
    """
    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.
    """
    landingFile = cf.data_dir + landingFile
    connectionsFile = cf.data_dir + connectionsFile
    countriesFile = cf.data_dir + countriesFile
    landing_File = csv.DictReader(open(landingFile, encoding="utf-8"),
                                  delimiter=",")
    connections_File = csv.DictReader(open(connectionsFile,
                                           encoding="utf-8-sig"),
                                      delimiter=",")
    countries_File = csv.DictReader(open(countriesFile, encoding="utf-8"),
                                    delimiter=",")

    # Creacion de listas vacias para agregar cada uno
    #  de los elementos de los archivos
    # y asi recorrerlos mas facilmente.
    listaLandingPoints = lt.newList('ARRAY_LIST')
    listaConnections = lt.newList('ARRAY_LIST')
    listaCountries = lt.newList('ARRAY_LIST')

    for punto in landing_File:
        model.addPosition(analyzer, punto)
        model.addLandingPointInfo(analyzer, punto)
        lt.addLast(listaLandingPoints, punto)

    for connection in connections_File:
        lt.addLast(listaConnections, connection)

    for pais in countries_File:
        lt.addLast(listaCountries, pais)
        model.addCountry(analyzer, pais)

    for point in lt.iterator(listaLandingPoints):
        nombre = point['name'].split(", ")
        if len(nombre) < 2:
            pais = 'Micronesia'
        else:
            pais = nombre[1]
        for country in lt.iterator(listaCountries):
            if country['CountryName'] == pais:
                capital = country['CapitalName'] + "-" + pais
                model.addPoint(analyzer, capital)
                datosCapital = country
                break

        lstPuntoActual = None
        for connection in lt.iterator(listaConnections):
            if connection['origin'] == point['landing_point_id']:
                lstPuntoActual = model.addLandingPoint(analyzer, point,
                                                       connection,
                                                       lstPuntoActual,
                                                       datosCapital)
        model.addConnectionsPoint(analyzer, lstPuntoActual)
    for country in lt.iterator(listaCountries):
        model.addCapitals(analyzer, country)
示例#12
0
def loadLandingPoints(catalog, landingpointsfile):
    landingpointsfile = cf.data_dir + landingpointsfile
    input_file = csv.DictReader(open(landingpointsfile, encoding="utf-8-sig"),
                                delimiter=",")
    for landingPoint in input_file:
        model.addLandingPoint(catalog, landingPoint)
示例#13
0
def loadLPs(catalog):
    filename = cf.data_dir + "landing_points.csv"
    input_file = csv.DictReader(open(filename, encoding="utf-8"),
                                delimiter=",")
    for lp in input_file:
        model.addLandingPoint(catalog, lp)