ESJL commited on
Commit
a1c2335
·
verified ·
1 Parent(s): 715dbd4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -1
app.py CHANGED
@@ -35,9 +35,39 @@ def carregar_abas(arquivo_excel):
35
  def listar_colunas(arquivo_excel, aba):
36
  if arquivo_excel is None or aba is None:
37
  return gr.update(choices=[]), gr.update(choices=[])
 
38
  df = pd.read_excel(arquivo_excel.name, sheet_name=aba)
39
  colunas = df.columns.tolist()
40
- return gr.update(choices=colunas), gr.update(choices=colunas)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
 
43
  def exibir_tabela(arquivo_excel, aba, coluna_num):
 
35
  def listar_colunas(arquivo_excel, aba):
36
  if arquivo_excel is None or aba is None:
37
  return gr.update(choices=[]), gr.update(choices=[])
38
+
39
  df = pd.read_excel(arquivo_excel.name, sheet_name=aba)
40
  colunas = df.columns.tolist()
41
+
42
+ # Criar versão upper para comparação
43
+ colunas_upper = {col.upper(): col for col in colunas}
44
+
45
+ # -----------------------------------
46
+ # Pré-seleção CDLOG
47
+ # -----------------------------------
48
+ coluna_cdlog_pre = None
49
+
50
+ if "CTM" in colunas_upper:
51
+ coluna_cdlog_pre = colunas_upper["CTM"]
52
+ elif "CDLOG" in colunas_upper:
53
+ coluna_cdlog_pre = colunas_upper["CDLOG"]
54
+
55
+ # -----------------------------------
56
+ # Pré-seleção Número
57
+ # -----------------------------------
58
+ coluna_num_pre = None
59
+
60
+ prioridades_num = ["Nº GEO", "NUM_GEO", "NUM"]
61
+
62
+ for nome in prioridades_num:
63
+ if nome.upper() in colunas_upper:
64
+ coluna_num_pre = colunas_upper[nome.upper()]
65
+ break
66
+
67
+ return (
68
+ gr.update(choices=colunas, value=coluna_cdlog_pre),
69
+ gr.update(choices=colunas, value=coluna_num_pre),
70
+ )
71
 
72
 
73
  def exibir_tabela(arquivo_excel, aba, coluna_num):