-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
154 lines (129 loc) · 5.08 KB
/
app.py
File metadata and controls
154 lines (129 loc) · 5.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import streamlit as st
import pandas as pd
from pathlib import Path
st.set_page_config(page_title="Evaluador Columnas Fijas", layout="wide")
# HARDCODEADO para ejemplo
COLUMNAS = [
{
'numero': 1,
'nombre': 'CATEGORY',
'descripcion': 'Category of the street (e.g., Primary, Secondary, Tertiary).',
'tipo': 'string'
},
{
'numero': 2,
'nombre': 'GIS_ID',
'descripcion': 'GIS identifier for the street.',
'tipo': 'string'
},
{
'numero': 3,
'nombre': 'OBJECTID',
'descripcion': 'Unique object identifier.',
'tipo': 'integer'
},
{
'numero': 4,
'nombre': 'GLOBALID',
'descripcion': 'Globally unique identifier.',
'tipo': 'string'
},
{
'numero': 5,
'nombre': 'SHAPEAREA',
'descripcion': 'Area of the street shape.',
'tipo': 'integer'
},
{
'numero': 6,
'nombre': 'SHAPELEN',
'descripcion': 'Length of the street shape.',
'tipo': 'integer'
}
]
total_columnas = len(COLUMNAS)
id_tabla = "01823609-f6ce-433b-866c-cf7a46b3ce2a"
st.title(f"Evaluador de tabla {id_tabla}")
csv_file = f"csvs/{id_tabla}.csv"
if Path(csv_file).exists():
df_csv = pd.read_csv(csv_file)
col_download1, _ = st.columns(2)
with col_download1:
csv_content = df_csv.to_csv(index=False).encode('utf-8')
st.download_button(
label="📥 **Descargar CSV original**",
data=csv_content,
file_name=csv_file,
mime="text/csv"
)
else:
st.warning(f"❌ {csv_file} no disponible.")
if 'columna_actual' not in st.session_state:
st.session_state.columna_actual = 0
if 'evaluaciones' not in st.session_state:
st.session_state.evaluaciones = {f"c{i}": {'nombre': {}, 'desc': {}, 'tipo': {}} for i in range(total_columnas)}
# Columna actual
columna_data = COLUMNAS[st.session_state.columna_actual]
st.header(f"**Columna #{columna_data['numero']}**")
st.subheader(f"**{columna_data['nombre']}**")
# st.markdown("### **Nombre | Descripción | Tipo de dato**")
tabla_data = pd.DataFrame([{
'Nombre': columna_data['nombre'],
'Descripción': columna_data['descripcion'],
'Tipo de dato': columna_data['tipo']
}])
st.table(tabla_data)
# Evaluaciones individuales para cada campo
st.subheader("**Evaluar cada campo**")
def evaluar_campo(campo_nombre, valor_campo, col_idx):
key = f"c{col_idx}_{campo_nombre}"
if key not in st.session_state.evaluaciones:
st.session_state.evaluaciones[key] = {
'correct': True,
'concise': True,
'justif_correct': '',
'justif_concise': ''
}
data = st.session_state.evaluaciones[key]
st.markdown(f"### **{campo_nombre.upper()}**: {valor_campo}")
col_correct, col_conciso = st.columns(2)
with col_correct:
data['correct'] = st.checkbox("**✓ Correcto**", value=data['correct'], key=f"chk_correct_{key}")
if not data['correct']:
data['justif_correct'] = st.text_area("**Justificación (incorrecto):**",
value=data['justif_correct'],
key=f"ta_correct_{key}", height=80)
with col_conciso:
data['concise'] = st.checkbox("**✨ Conciso**", value=data['concise'], key=f"chk_concise_{key}")
if not data['concise']:
data['justif_concise'] = st.text_area("**Justificación (no conciso):**",
value=data['justif_concise'],
key=f"ta_concise_{key}", height=80)
st.session_state.evaluaciones[key] = data
return st.container()
# Evaluar los 3 campos
evaluar_campo('nombre', columna_data['nombre'], st.session_state.columna_actual)
evaluar_campo('descripcion', columna_data['descripcion'], st.session_state.columna_actual)
evaluar_campo('tipo', columna_data['tipo'], st.session_state.columna_actual)
# Navegación principal
col_prev, col_next, col_slider = st.columns([1, 1, 2])
with col_prev:
if st.button("**◀️ Columna Anterior**", disabled=st.session_state.columna_actual == 0):
st.session_state.columna_actual -= 1
st.rerun()
with col_next:
if st.button("**▶️ Siguiente Columna**", type="primary", disabled=st.session_state.columna_actual == total_columnas - 1):
st.session_state.columna_actual += 1
st.rerun()
# with col_slider:
# st.session_state.columna_actual = st.slider("Navegar:", 0, total_columnas-1, st.session_state.columna_actual)
# Sidebar: Botones rápidos por columna
st.sidebar.header("**Ir a columna**")
for i, col in enumerate(COLUMNAS):
if st.sidebar.button(f"#{col['numero']} {col['nombre']}"):
st.session_state.columna_actual = i
st.rerun()
# Barra de progreso
# progreso = sum(len(st.session_state.evaluaciones[k]) > 0 for k in st.session_state.evaluaciones) / (total_columnas * 3)
# st.progress(progreso)
# st.metric("Campos completados", f"{int(progreso * total_columnas * 3)} / {total_columnas * 3}")