table-stream 0.2.8__tar.gz → 0.2.9.5__tar.gz
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.
- {table_stream-0.2.8 → table_stream-0.2.9.5}/PKG-INFO +3 -4
- {table_stream-0.2.8 → table_stream-0.2.9.5}/pyproject.toml +4 -4
- {table_stream-0.2.8 → table_stream-0.2.9.5}/table_stream/__init__.py +93 -17
- {table_stream-0.2.8 → table_stream-0.2.9.5}/table_stream.egg-info/PKG-INFO +3 -4
- table_stream-0.2.9.5/table_stream.egg-info/requires.txt +2 -0
- table_stream-0.2.8/table_stream.egg-info/requires.txt +0 -3
- {table_stream-0.2.8 → table_stream-0.2.9.5}/README.md +0 -0
- {table_stream-0.2.8 → table_stream-0.2.9.5}/setup.cfg +0 -0
- {table_stream-0.2.8 → table_stream-0.2.9.5}/table_stream.egg-info/SOURCES.txt +0 -0
- {table_stream-0.2.8 → table_stream-0.2.9.5}/table_stream.egg-info/dependency_links.txt +0 -0
- {table_stream-0.2.8 → table_stream-0.2.9.5}/table_stream.egg-info/top_level.txt +0 -0
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: table_stream
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.9.5
|
|
4
4
|
Summary: Tipos de dados e implementações para o uso em tabelas.
|
|
5
5
|
Requires-Python: >=3.12
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
7
|
-
Requires-Dist: openpyxl
|
|
8
|
-
Requires-Dist: pandas
|
|
9
|
-
Requires-Dist: pandas-stubs~=3.0.0
|
|
7
|
+
Requires-Dist: openpyxl==3.1.5
|
|
8
|
+
Requires-Dist: pandas==3.0.0
|
|
10
9
|
|
|
11
10
|
# table_stream
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "table_stream"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.9.5"
|
|
4
4
|
description = "Tipos de dados e implementações para o uso em tabelas."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12"
|
|
7
7
|
dependencies = [
|
|
8
|
-
"openpyxl
|
|
9
|
-
"pandas
|
|
10
|
-
"pandas-stubs~=3.0.0",
|
|
8
|
+
"openpyxl==3.1.5",
|
|
9
|
+
"pandas==3.0.0",
|
|
11
10
|
]
|
|
12
11
|
|
|
13
12
|
[dependency-groups]
|
|
14
13
|
dev = [
|
|
15
14
|
"build>=1.4.0",
|
|
16
15
|
"twine>=6.2.0",
|
|
16
|
+
"pandas-stubs~=3.0.0",
|
|
17
17
|
]
|
|
18
18
|
|
|
19
19
|
[tool.setuptools.packages.find]
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
-
#from collections.abc import Iterable
|
|
3
2
|
|
|
4
|
-
from abc import
|
|
3
|
+
# from collections.abc import Iterable
|
|
4
|
+
|
|
5
|
+
from abc import abstractmethod, ABC # ABCMeta
|
|
5
6
|
from typing import (
|
|
6
7
|
Any,
|
|
7
8
|
Callable,
|
|
@@ -26,7 +27,8 @@ from zipfile import ZipFile
|
|
|
26
27
|
|
|
27
28
|
import json
|
|
28
29
|
from pandas import DataFrame
|
|
29
|
-
|
|
30
|
+
|
|
31
|
+
# from pandas import Series
|
|
30
32
|
import pandas as pd
|
|
31
33
|
|
|
32
34
|
__version__ = "0.2.8"
|
|
@@ -644,7 +646,9 @@ class HashMapDict[K, T](HashMap):
|
|
|
644
646
|
|
|
645
647
|
def to_map_str(self) -> dict[str, Any]:
|
|
646
648
|
final = dict()
|
|
647
|
-
|
|
649
|
+
_header = self.header()
|
|
650
|
+
|
|
651
|
+
for i in _header:
|
|
648
652
|
final[str(i)] = str(self.get_value(i))
|
|
649
653
|
return final
|
|
650
654
|
|
|
@@ -895,7 +899,9 @@ class Listener[NOTIFIER](ABC):
|
|
|
895
899
|
|
|
896
900
|
def _read_notifier(self, type_notifier: type[NOTIFIER]) -> NOTIFIER:
|
|
897
901
|
if self.type_notifier is None:
|
|
898
|
-
raise ValueError(
|
|
902
|
+
raise ValueError(
|
|
903
|
+
f"Nenhum notificador foi definido em ... {__class__.__name__}()"
|
|
904
|
+
)
|
|
899
905
|
return self._watched[type_notifier]
|
|
900
906
|
|
|
901
907
|
def read(self) -> NOTIFIER:
|
|
@@ -3213,8 +3219,11 @@ class DataStorage(Observable[pd.DataFrame]):
|
|
|
3213
3219
|
|
|
3214
3220
|
class DataReader(object):
|
|
3215
3221
|
|
|
3216
|
-
def __init__(self, store: DataStorage) -> None:
|
|
3222
|
+
def __init__(self, store: DataStorage | None = None) -> None:
|
|
3217
3223
|
super().__init__()
|
|
3224
|
+
if store is None:
|
|
3225
|
+
store = DataStorage()
|
|
3226
|
+
|
|
3218
3227
|
self._store = store
|
|
3219
3228
|
|
|
3220
3229
|
def read(self, path: File) -> pd.DataFrame:
|
|
@@ -3233,10 +3242,10 @@ class DataSave(Observer[pd.DataFrame]):
|
|
|
3233
3242
|
Salvar o DataFrame() em um arquivo sempre receber uma notificação.
|
|
3234
3243
|
"""
|
|
3235
3244
|
|
|
3236
|
-
def __init__(self, path_sheet: File) -> None:
|
|
3245
|
+
def __init__(self, path_sheet: File | None = None) -> None:
|
|
3237
3246
|
super().__init__()
|
|
3238
|
-
self.path_sheet: File = path_sheet
|
|
3239
|
-
self.csv_options: CsvOptions = CsvOptions()
|
|
3247
|
+
self.path_sheet: File | None = path_sheet
|
|
3248
|
+
self.csv_options: CsvOptions = CsvOptions(encoding="utf-8", separator="\t")
|
|
3240
3249
|
self.debug: bool = True
|
|
3241
3250
|
|
|
3242
3251
|
def _show(self, txt: str) -> None:
|
|
@@ -3246,6 +3255,9 @@ class DataSave(Observer[pd.DataFrame]):
|
|
|
3246
3255
|
|
|
3247
3256
|
def update(self, value: pd.DataFrame) -> None:
|
|
3248
3257
|
|
|
3258
|
+
if self.path_sheet is None:
|
|
3259
|
+
raise ValueError(f"{__class__.__name__} o arquivo de destino é nulo.")
|
|
3260
|
+
|
|
3249
3261
|
self._show(f"Salvando ... {self.path_sheet.absolute()}")
|
|
3250
3262
|
|
|
3251
3263
|
if self.path_sheet.is_csv():
|
|
@@ -3282,6 +3294,7 @@ class SplitterData(Notifier):
|
|
|
3282
3294
|
def split(self, df: pd.DataFrame, output: Directory) -> None:
|
|
3283
3295
|
if df.empty:
|
|
3284
3296
|
return None
|
|
3297
|
+
df = df.astype(str)
|
|
3285
3298
|
|
|
3286
3299
|
self.output_dir = output
|
|
3287
3300
|
values_split = Set(df[self.col_split].drop_duplicates().values.tolist())
|
|
@@ -3306,16 +3319,42 @@ class SplitterData(Notifier):
|
|
|
3306
3319
|
return super().notify_listeners()
|
|
3307
3320
|
|
|
3308
3321
|
|
|
3309
|
-
class
|
|
3322
|
+
class ListenerSplitter(Listener[SplitterData]):
|
|
3310
3323
|
|
|
3311
3324
|
def __init__(self) -> None:
|
|
3312
3325
|
super().__init__()
|
|
3313
|
-
self.saver = DataSave(
|
|
3326
|
+
self.saver = DataSave()
|
|
3327
|
+
|
|
3328
|
+
def set_csv_options(self, opt: CsvOptions):
|
|
3329
|
+
self.saver.csv_options = opt
|
|
3314
3330
|
|
|
3315
3331
|
def receiver_notifier(self) -> None:
|
|
3316
3332
|
sp = self.read()
|
|
3317
3333
|
self.update(sp)
|
|
3318
3334
|
|
|
3335
|
+
def create_export_files(self, d: Directory, filename: str) -> Set[File]:
|
|
3336
|
+
dir_excel = d.concat("EXCEL", True)
|
|
3337
|
+
dir_csv = d.concat("CSV", True)
|
|
3338
|
+
|
|
3339
|
+
path_excel = dir_excel.join_file(f"{filename}.xlsx")
|
|
3340
|
+
path_csv = dir_csv.join_file(f"{filename}.csv")
|
|
3341
|
+
return Set([path_excel, path_csv])
|
|
3342
|
+
|
|
3343
|
+
def _run_export(self, df: pd.DataFrame, files: Set[File]) -> None:
|
|
3344
|
+
"""
|
|
3345
|
+
Exporta o mesmo DataFrame() para varios caminhos/arquivos
|
|
3346
|
+
|
|
3347
|
+
util para exportar csv/excel
|
|
3348
|
+
"""
|
|
3349
|
+
|
|
3350
|
+
if files.empty():
|
|
3351
|
+
return None
|
|
3352
|
+
|
|
3353
|
+
f: File
|
|
3354
|
+
for f in files:
|
|
3355
|
+
self.saver.path_sheet = f
|
|
3356
|
+
self.saver.update(df)
|
|
3357
|
+
|
|
3319
3358
|
def update(self, value: SplitterData) -> None:
|
|
3320
3359
|
if value.output_dir is None:
|
|
3321
3360
|
return
|
|
@@ -3325,12 +3364,49 @@ class DataExport(Listener):
|
|
|
3325
3364
|
d = value.output_dir
|
|
3326
3365
|
d.mkdir()
|
|
3327
3366
|
|
|
3328
|
-
|
|
3367
|
+
final_filename: str = str(value.current_file_name)
|
|
3329
3368
|
|
|
3330
3369
|
if value.current_prefix is not None:
|
|
3331
|
-
|
|
3370
|
+
final_filename = f"{value.current_prefix}-{final_filename}"
|
|
3371
|
+
|
|
3372
|
+
print(f"Progresso: [{value.done}/{value.total_export}]")
|
|
3373
|
+
|
|
3374
|
+
files = self.create_export_files(d, final_filename)
|
|
3375
|
+
df = value.storage.get_data()
|
|
3376
|
+
self._run_export(df, files)
|
|
3377
|
+
|
|
3378
|
+
|
|
3379
|
+
class ListenerSplitterQgiz(ListenerSplitter):
|
|
3332
3380
|
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3381
|
+
def __init__(self) -> None:
|
|
3382
|
+
super().__init__()
|
|
3383
|
+
|
|
3384
|
+
def create_export_files(self, d: Directory, filename: str) -> Set[File]:
|
|
3385
|
+
sp = self.read()
|
|
3386
|
+
current_data = sp.storage.get_data()
|
|
3387
|
+
cols = ArrayList(current_data.columns.to_list())
|
|
3388
|
+
|
|
3389
|
+
dir_excel = d.concat("EXCEL", True)
|
|
3390
|
+
dir_csv = d.concat("CSV", True)
|
|
3391
|
+
|
|
3392
|
+
col_ano = "numano"
|
|
3393
|
+
col_mes = "nummes"
|
|
3394
|
+
|
|
3395
|
+
if cols.contains(col_ano):
|
|
3396
|
+
ano = str(current_data[col_ano].values.tolist()[0])
|
|
3397
|
+
|
|
3398
|
+
dir_excel = dir_excel.concat(ano, True)
|
|
3399
|
+
dir_csv = dir_csv.concat(ano, True)
|
|
3400
|
+
|
|
3401
|
+
if cols.contains(col_mes):
|
|
3402
|
+
mes = str(current_data[col_mes].values.tolist()[0])
|
|
3403
|
+
|
|
3404
|
+
dir_excel = dir_excel.concat(mes, True)
|
|
3405
|
+
dir_csv = dir_csv.concat(mes, True)
|
|
3406
|
+
|
|
3407
|
+
return Set.from_list(
|
|
3408
|
+
[
|
|
3409
|
+
dir_excel.join_file(f"{filename}.xlsx"),
|
|
3410
|
+
dir_csv.join_file(f"{filename}.csv"),
|
|
3411
|
+
]
|
|
3412
|
+
)
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: table_stream
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.9.5
|
|
4
4
|
Summary: Tipos de dados e implementações para o uso em tabelas.
|
|
5
5
|
Requires-Python: >=3.12
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
7
|
-
Requires-Dist: openpyxl
|
|
8
|
-
Requires-Dist: pandas
|
|
9
|
-
Requires-Dist: pandas-stubs~=3.0.0
|
|
7
|
+
Requires-Dist: openpyxl==3.1.5
|
|
8
|
+
Requires-Dist: pandas==3.0.0
|
|
10
9
|
|
|
11
10
|
# table_stream
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|