Repository for the billing history of ISM GOMES DE MATTOS, covering the years 2024 and 2025.
This is a public version of the README, with all sensitive data removed.
All mentions of units or billing data are for educational and demonstrative purposes only.
The billing includes:
- All UFC RUs in Fortaleza
- The HGF (Hospital Geral de Fortaleza)
- The IJF (Instituto Doutor José Frota)
- Several UPAs
- The UFPB (Federal University of Paraíba)
- The UNB (University of Brasília)
- And approximately 33 more units, mostly federal hospitals and universities.
The project reads and consolidates multiple data tables into a standardized format, classifies them, and corrects inconsistencies.
Data originates from billing exports, with one definitive file per unit and period.
C:\historico-faturamento\Planning\example_File\tabela_parsing_df-v3.xlsx
try:
classf_Tab_Dir = glob.glob("C:\\*\\*\\HRN\\Classf\\*")
print(str(classf_Tab_Dir[0]))
classfTab = pd.read_excel(f"{str(classf_Tab_Dir[0])}")
except (IndexError, OSError):
raise OSError("Classification table not found. Check your directory structure.")CR_HRN_2023_15_12_2024_14_1.xlsx
historico-faturamento/
├── Input/
│ └── HRN/
│ └── 2024/
│ └── 1-2023_15_12_2024_14_1/
│ └── CR_HRN_2023_15_12_2024_14_1.xlsx
├── Output/
│ └── HRN_output.xlsx
└── Planning/
└── example_File/
└── tabela_parsing_df-v3.xlsx
C:\historico-faturamento\Planning\example_File\tabela_parsing_df-v3.xlsx
Caution
Keep this structure consistent — otherwise scripts won’t locate the classification table!
Input:
C:\historico-faturamento\Input\HRN\2024\1-2023_15_12_2024_14_1\CR_HRN_2023_15_12_2024_14_1.xlsx
Output:
C:\historico-faturamento\Output\HRN\HRN_output.xlsx
C:\historico-faturamento
Warning
Always keep this folder name consistent to prevent path errors in unit scripts.
\Input: manually created\Output: only the root folder must exist — subfolders are auto-generated
output_base_dir = r"C:\historico-faturamento\Output\HRN"
os.makedirs(output_base_dir, exist_ok=True)1-2023_15_12_2024_14_1
- Month:
1- - Start Date:
2023_15_12 - End Date:
2024_14_1
Caution
Avoid leading zeros — use 2024_1_2, not 2024_01_02.
CR_HRN_2023_15_12_2024_14_1.xlsx
- CR → File classification
- HRN → Unit
- 2023_15_12 → Start date
- 2024_14_1 → End date
- .xlsx → File extension
The scripts extract metadata from filenames rather than the document contents.
This is because the information inside the files is often inconsistent or missing, and using filenames ensures a standardized, reliable reference for all processing.
Example reference table construction:
tab = pd.DataFrame(dados_arquivos)
tab["nome_arquivo"] = arquivos
tab.loc[:,6] = tab.loc[:,6].astype(int)
tab.loc[:,9] = tab.loc[:,9].astype(int)
selectedrows = tab[tab[5] == "2025"].sort_values(by=6)
tab = tab[tab[5] == "2024"].sort_values(by=6)
tab = pd.concat([tab, selectedrows], axis=0)These names determine:
- Chronological order
- Competence period assignment
- Iteration management (
tabIteration)
Example of extracting competence:
comp_inicio = f"{tab.iloc[int(tabIteration), 16]}/{yearMonths[(int(tab.iloc[tabIteration, 17])-1)].upper()} de {tab.iloc[tabIteration, 15]}"
comp_fim = f"{tab.iloc[int(tabIteration), 19]}/{yearMonths[(int(tab.iloc[tabIteration, 20])-1)].upper()} de {tab.iloc[tabIteration, 18]}"To add a new competence period:
- Create the folder for the new month (and year if needed).
- Place the new
.xlsxinput file inside. - Follow naming conventions.
- Run the script and review output.
Note
Example competence folders are available in:
C:\historico-faturamento\Planning\CompfileStructure\2025
Each unit has a dedicated Python script due to structural differences between tables.
Simpler units process quickly; others require complex parsing and validation logic.
Repositório para histórico de faturamento da ISM GOMES DE MATTOS, referente aos anos 2024 e 2025.
Esta é uma versão pública do README, com todos os dados sensíveis removidos.
Todas as menções a unidades ou faturamento são apenas para fins educacionais.
O faturamento inclui:
- Todos os RUs da UFC em Fortaleza
- O HGF (Hospital Geral de Fortaleza)
- O IJF (Instituto Doutor José Frota)
- Diversas UPAs
- UFPB (Universidade Federal da Paraíba)
- UNB (Universidade de Brasília)
- E aproximadamente 33 outras unidades, principalmente hospitais e universidades federais.
O projeto lê múltiplas tabelas, consolida em formato padronizado, classifica e corrige inconsistências.
Os dados provêm de exportações do sistema de faturamento, com um arquivo definitivo por unidade e período.
C:\historico-faturamento\Planning\example_File\tabela_parsing_df-v3.xlsx
try:
classf_Tab_Dir = glob.glob("C:\\*\\*\\HRN\\Classf\\*")
print(str(classf_Tab_Dir[0]))
classfTab = pd.read_excel(f"{str(classf_Tab_Dir[0])}")
except (IndexError, OSError):
raise OSError("Tabela de classificação não encontrada. Verifique a estrutura de pastas.")CR_HRN_2023_15_12_2024_14_1.xlsx
historico-faturamento/
├── Input/
│ └── HRN/
│ └── 2024/
│ └── 1-2023_15_12_2024_14_1/
│ └── CR_HRN_2023_15_12_2024_14_1.xlsx
├── Output/
│ └── HRN_output.xlsx
└── Planning/
└── example_File/
└── tabela_parsing_df-v3.xlsx
C:\historico-faturamento\Planning\example_File\tabela_parsing_df-v3.xlsx
Caution
Mantenha esta estrutura consistente — caso contrário, os scripts não localizarão a tabela de classificação.
Input:
C:\historico-faturamento\Input\HRN\2024\1-2023_15_12_2024_14_1\CR_HRN_2023_15_12_2024_14_1.xlsx
Output:
C:\historico-faturamento\Output\HRN\HRN_output.xlsx
C:\historico-faturamento
Warning
Mantenha este nome de pasta consistente para evitar erros nos scripts das unidades.
\Input: criado manualmente\Output: somente a pasta raiz deve existir — subpastas são criadas automaticamente
output_base_dir = r"C:\historico-faturamento\Output\HRN"
os.makedirs(output_base_dir, exist_ok=True)1-2023_15_12_2024_14_1
- Mês:
1- - Data Inicial:
2023_15_12 - Data Final:
2024_14_1
Caution
Evite zeros à esquerda — use 2024_1_2, não 2024_01_02.
CR_HRN_2023_15_12_2024_14_1.xlsx
- CR → classificação do arquivo
- HRN → unidade
- 2023_15_12 → data de início
- 2024_14_1 → data de término
- .xlsx → extensão
Os scripts extraem metadados dos nomes de arquivos e não do conteúdo dos documentos.
Isso ocorre porque os dados dentro dos arquivos frequentemente estão inconsistentes ou ausentes, e usar os nomes garante uma referência padronizada e confiável.
Exemplo de construção da tabela de referência:
tab = pd.DataFrame(dados_arquivos)
tab["nome_arquivo"] = arquivos
tab.loc[:,6] = tab.loc[:,6].astype(int)
tab.loc[:,9] = tab.loc[:,9].astype(int)
selectedrows = tab[tab[5] == "2025"].sort_values(by=6)
tab = tab[tab[5] == "2024"].sort_values(by=6)
tab = pd.concat([tab, selectedrows], axis=0)Os nomes determinam:
- Ordem cronológica
- Atribuição do período de competência
- Controle de iteração (
tabIteration)
Exemplo de extração da competência:
comp_inicio = f"{tab.iloc[int(tabIteration), 16]}/{yearMonths[(int(tab.iloc[tabIteration, 17])-1)].upper()} de {tab.iloc[tabIteration, 15]}"
comp_fim = f"{tab.iloc[int(tabIteration), 19]}/{yearMonths[(int(tab.iloc[tabIteration, 20])-1)].upper()} de {tab.iloc[tabIteration, 18]}"Para adicionar um novo período de competência:
- Crie a pasta para o novo mês (e ano, se necessário).
- Coloque o arquivo
.xlsxdentro. - Siga as convenções de nomenclatura.
- Execute o script e revise o output.
Note
Exemplos de pastas de competência estão disponíveis em:
C:\historico-faturamento\Planning\CompfileStructure\2025
Cada unidade possui um script Python dedicado devido às diferenças estruturais entre as tabelas.
Unidades simples processam rapidamente; outras exigem parsing e validações mais complexas.