Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
|
|
|
|
|
|
|
| 3 |
# ######################
|
| 4 |
# Configuración de página
|
| 5 |
# ######################
|
|
@@ -32,6 +34,30 @@ tab1, tab2 = st.tabs(["Excel", "Manual"])
|
|
| 32 |
|
| 33 |
with tab1:
|
| 34 |
uploaded_file = st.file_uploader("Elige un archivo", accept_multiple_files=False, type=["xlsx"], help="Solo acepta excel")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
|
| 3 |
+
import streamlit as st
|
| 4 |
+
|
| 5 |
# ######################
|
| 6 |
# Configuración de página
|
| 7 |
# ######################
|
|
|
|
| 34 |
|
| 35 |
with tab1:
|
| 36 |
uploaded_file = st.file_uploader("Elige un archivo", accept_multiple_files=False, type=["xlsx"], help="Solo acepta excel")
|
| 37 |
+
if uploaded_file is not None:
|
| 38 |
+
st.write(uploaded_file.name)
|
| 39 |
+
|
| 40 |
+
datos = pd.read_excel(uploaded_file, sheet_name=None)
|
| 41 |
+
nombres_hojas = list(datos.keys())
|
| 42 |
+
|
| 43 |
+
if "Distancias" not in nombres_hojas or "Demandas_clientes" not in nombres_hojas or "Capacidad_vehiculos" not in nombres_hojas:
|
| 44 |
+
st.error("Falta una hoja", icon = "❌")
|
| 45 |
+
|
| 46 |
+
else:
|
| 47 |
+
#names permite añadir nombres, si no pandas añade directamente int desde 0.
|
| 48 |
+
valores = dict()
|
| 49 |
+
for hoja in ["Num_nodos", "Distancias", "Demandas_clientes", "Num_vehiculos", "Capacidad_vehiculos"]: # Usa 'openpyxl' como motor para leer archivos xlsx
|
| 50 |
+
#dataframe = pd.read_excel('6. Algoritmo genético.py\Datos.xlsx', sheet_name= hoja, header=None, names=[]) #Si el archivo estuviera en la carpeta, no cargado
|
| 51 |
+
if hoja in nombres_hojas:
|
| 52 |
+
dataframe = pd.read_excel(uploaded_file, engine='openpyxl', sheet_name=hoja, header=None, names=[])
|
| 53 |
+
matriz = dataframe.values.tolist()
|
| 54 |
+
valores[hoja] = matriz
|
| 55 |
+
|
| 56 |
+
if "Num_nodos" in nombres_hojas: num_nodos = valores["Num_nodos"][0][0]
|
| 57 |
+
distancias = valores["Distancias"]
|
| 58 |
+
demandas_clientes = [valor[0] for valor in valores["Demandas_clientes"]]
|
| 59 |
+
if "Num_vehiculos" in nombres_hojas: num_vehiculos = valores["Num_vehiculos"][0][0]
|
| 60 |
+
capacidad_vehiculos = [valor[0] for valor in valores["Capacidad_vehiculos"]]
|
| 61 |
|
| 62 |
|
| 63 |
|