python-generate-xlsx-report 0.0.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
File without changes
@@ -0,0 +1,97 @@
1
+ from openpyxl import load_workbook
2
+ from openpyxl.utils import get_column_letter
3
+ import logging
4
+
5
+ logging.basicConfig(level=logging.DEBUG)
6
+
7
+
8
+ def add_numeric_sheet_to_file(path: str) -> None:
9
+ """Exporta um novo xlsx com todo o conteúdo do arquivo informado no path,
10
+ adicionado um sheet (planilha) contendo apenas as colunas numéricas do
11
+ arquivo enviado.
12
+
13
+ Args:
14
+ path (str): O caminho do arquivo xlsx com o nome a extensão. Exemplo:
15
+ assets/sample.xlsx
16
+ """
17
+ numeric_new_file = path.replace('.xlsx', '_numeric.xlsx')
18
+
19
+ wb_original = load_workbook(path)
20
+
21
+ wb_original.save(numeric_new_file)
22
+ wb_new = load_workbook(numeric_new_file)
23
+
24
+ sheets = wb_original.sheetnames
25
+
26
+ for sheet_name in sheets:
27
+ numeric_sheet_name = f"numeric_{sheet_name}"
28
+ if numeric_sheet_name not in wb_new.sheetnames:
29
+ wb_new.create_sheet(numeric_sheet_name)
30
+
31
+ old_sheet = wb_original[sheet_name]
32
+ numeric_sheet = wb_new[numeric_sheet_name]
33
+
34
+ for col in old_sheet.iter_cols():
35
+ if all(isinstance(cell.value, (int, float)) or cell.row == 1 for cell in col):
36
+ for cell in col:
37
+ numeric_sheet.cell(row=cell.row, column=cell.column, value=cell.value)
38
+
39
+ wb_new.save(numeric_new_file)
40
+
41
+ for col in reversed(list(numeric_sheet.iter_cols(min_row=1, max_row=numeric_sheet.max_row, min_col=1, max_col=numeric_sheet.max_column))):
42
+ if all(cell.value is None for cell in col):
43
+ numeric_sheet.delete_cols(col[0].column)
44
+
45
+ wb_new.save(numeric_new_file)
46
+
47
+
48
+ def gera_metrica(path: str):
49
+ """Gera as métricas (Média, Máximo, Mínimo e Somatória) dos campos numéricos presentes
50
+ no arquivo xlsx fornecido no path.
51
+
52
+ Args:
53
+ path (str): O caminho do arquivo xlsx com o nome a extensão. Exemplo:
54
+ assets/sample.xlsx
55
+ """
56
+ numeric_path = path.replace('.xlsx', '_numeric.xlsx')
57
+ report_path = path.replace(".xlsx", "_analise_quantitativa.xlsx")
58
+ wb_original = load_workbook(numeric_path)
59
+
60
+ wb_original.save(report_path)
61
+ wb_new = load_workbook(report_path)
62
+
63
+ wb_new.create_sheet("AnaliseQuantitativa")
64
+ wb_new.save(report_path)
65
+
66
+ sheets: list = wb_original.sheetnames
67
+
68
+ for sheet in sheets:
69
+ if "numeric_" in sheet:
70
+ current_sheet = sheet
71
+
72
+ col_names = [cel.value for cel in wb_original[current_sheet][1]]
73
+ wb_analise = wb_new["AnaliseQuantitativa"]
74
+
75
+ for col_index, name in enumerate(col_names, start=1):
76
+ col_letter = get_column_letter(col_index)
77
+ logging.info("Gerando a Somatória")
78
+ wb_analise[f"{col_letter}1"] = f"Somatória: {name}"
79
+ wb_analise[f"{col_letter}2"] = f"=SUM({sheet}!{col_letter}:{col_letter})"
80
+ logging.info("Gerando a média")
81
+ wb_analise[f"{col_letter}5"] = f"Média: {name}"
82
+ wb_analise[f"{col_letter}6"] = f"=AVERAGE({sheet}!{col_letter}:{col_letter})"
83
+ logging.info("Gerando o máximo")
84
+ wb_analise[f"{col_letter}9"] = f"Máximo: {name}"
85
+ wb_analise[f"{col_letter}10"] = f"=MAX({sheet}!{col_letter}:{col_letter})"
86
+ logging.info("Gerando o minimo")
87
+ wb_analise[f"{col_letter}13"] = f"Mínimo: {name}"
88
+ wb_analise[f"{col_letter}14"] = f"=MIN({sheet}!{col_letter}:{col_letter})"
89
+
90
+ wb_new.save(report_path)
91
+ logging.info("Relatório gerado com sucesso.")
92
+
93
+
94
+ if __name__ == "__main__":
95
+ sample_file = "assets/sample.xlsx"
96
+ add_numeric_sheet_to_file(sample_file)
97
+ gera_metrica(sample_file)
File without changes
@@ -0,0 +1,33 @@
1
+ Metadata-Version: 2.4
2
+ Name: python_generate_xlsx_report
3
+ Version: 0.0.10
4
+ Summary: Um gerador de relatório de análise quantitativa e qualitativa
5
+ Home-page: https://github.com/DadosComCafe/vigilante
6
+ Author: dadoscomcafe
7
+ Author-email: dadoscomcafe.dev@gmail.com
8
+ License: MIT
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.12
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: openpyxl==3.1.5
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: classifier
19
+ Dynamic: description
20
+ Dynamic: description-content-type
21
+ Dynamic: home-page
22
+ Dynamic: license
23
+ Dynamic: license-file
24
+ Dynamic: requires-dist
25
+ Dynamic: requires-python
26
+ Dynamic: summary
27
+
28
+ # python-xlsx-autoreport
29
+ Um pacote usado para facilitar a criação de relatórios de análise quantitativa.
30
+
31
+
32
+ Você encontrará dados inválidos com mais facilidade
33
+ ![Validador](python_xlsx_autoreport/src/assets/vigilante_bob_esponja.png)
@@ -0,0 +1,9 @@
1
+ python_generate_xlsx_report/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ python_generate_xlsx_report/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ python_generate_xlsx_report/src/python_generate_xlsx_report.py,sha256=ASh3yHO-r2Yya5Kvq6C93-z7lVz70-oLUhjeaBaCJuc,3547
4
+ python_generate_xlsx_report/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ python_generate_xlsx_report-0.0.10.dist-info/licenses/LICENSE,sha256=FRRVaEwB24O_1A0x3j6h2pFaAf_uhx_gt5BC7pMr8_U,1068
6
+ python_generate_xlsx_report-0.0.10.dist-info/METADATA,sha256=mTz78UFZV6dieHgG53jl4i2z2Xq7RPiuAo_Hma3ZmfE,1016
7
+ python_generate_xlsx_report-0.0.10.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
8
+ python_generate_xlsx_report-0.0.10.dist-info/top_level.txt,sha256=ErS9BMnIYcNq4JcLCpkBI9N4TN4QrV5ij9mLsRm-8QM,28
9
+ python_generate_xlsx_report-0.0.10.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (79.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 DadosComCafe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ python_generate_xlsx_report