Skip to content

Commit

Permalink
feat: adicionar multiplos schema
Browse files Browse the repository at this point in the history
  • Loading branch information
lvgalvao committed Jan 20, 2024
1 parent 66aa7c0 commit db8f685
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 19 deletions.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions 00-automacao-data-qualiy-excel-etl/src/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def process_excel(uploaded_file, model_name):
raise ValueError(f"Modelo desconhecido: {model_name}")

# Verificar se há colunas extras no DataFrame
extra_cols = set(df.columns) - set(schema.model_fields.keys())
extra_cols = set(df.columns) - set(schema.__annotations__.keys())
if extra_cols:
return False, f"Colunas extras detectadas no Excel: {', '.join(extra_cols)}"

Expand All @@ -25,7 +25,7 @@ def process_excel(uploaded_file, model_name):
try:
_ = schema(**row.to_dict())
except Exception as e:
raise ValueError(f"Erro na linha {index + 2}: {e}") # +2 porque o índice começa em 0 e a primeira linha do Excel é o cabeçalho
raise ValueError(f"Erro na linha {index + 2}: {e}")

return True, None

Expand Down
3 changes: 2 additions & 1 deletion 00-automacao-data-qualiy-excel-etl/src/contrato.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pydantic import BaseModel
from pydantic import BaseModel, EmailStr

class UsuarioSchema(BaseModel):
nome: str
Expand All @@ -9,6 +9,7 @@ class VendasSchema(BaseModel):
produto: str
quantidade: int
preco: float
email: EmailStr

class RecursosHumanosSchema(BaseModel):
funcionario: str
Expand Down
16 changes: 0 additions & 16 deletions 00-automacao-data-qualiy-excel-etl/src/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,3 @@ def display_results(self, result, error):
st.error(f"Erro na validação: {error}")
else:
st.success("O schema do arquivo Excel está correto!")

# import streamlit as st

# def set_page_config():
# st.set_page_config(page_title="Validador de Schema de Excel", layout="wide")

# def show_ui():
# st.title("Validador de Schema de Excel")
# uploaded_file = st.file_uploader("Carregue seu arquivo Excel aqui", type=["xlsx"])
# return uploaded_file

# def display_results(result, error):
# if error:
# st.error(f"Erro na validação: {error}")
# else:
# st.success("O schema do arquivo Excel está correto!")

0 comments on commit db8f685

Please sign in to comment.