import ast


def get_edgesID(row, columns):
    """
    The ABM stores the sequence of edgeIDs traversed in each route in different columns, given the 254 characters limit per field.
    This functions merges such lists in one List.
     
    Parameters
    ----------
    row: Pandas Series
        A row of the GeoDataFrame containing the routes
    columns: List of String
        A routes GeoDataFrame's columns
        
    Returns
    -------
    List of Integer
    """
    
    edgeID_string = row['edgeIDs_0']
    counter = 1
    while True:
        if 'edgeIDs_'+str(counter) not in columns:
            break
        if row['edgeIDs_'+str(counter)] is None:
            break
        edgeID_string = edgeID_string + row['edgeIDs_'+str(counter)]
        counter += 1

    return ast.literal_eval(edgeID_string)