python-table-processor 0.3.7__py3-none-any.whl → 0.3.9__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.
- {python_table_processor-0.3.7.dist-info → python_table_processor-0.3.9.dist-info}/METADATA +1 -1
- {python_table_processor-0.3.7.dist-info → python_table_processor-0.3.9.dist-info}/RECORD +9 -9
- table_processor/__init__.py +2 -2
- table_processor/commands/merge_tables.py +6 -0
- table_processor/core/actions.py +5 -5
- table_processor/core/merge.py +28 -15
- {python_table_processor-0.3.7.dist-info → python_table_processor-0.3.9.dist-info}/LICENSE +0 -0
- {python_table_processor-0.3.7.dist-info → python_table_processor-0.3.9.dist-info}/WHEEL +0 -0
- {python_table_processor-0.3.7.dist-info → python_table_processor-0.3.9.dist-info}/entry_points.txt +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
table_processor/__init__.py,sha256=
|
|
1
|
+
table_processor/__init__.py,sha256=sA4b5QjPy1l9_d8B5UqNxW9ElcTD5ccsduZThd_EcI0,52
|
|
2
2
|
table_processor/cli.py,sha256=uluf_VsBzq3Ldxh3ePGseSrv8--lI7huu-6RjDaHPPg,2170
|
|
3
3
|
table_processor/commands/convert_tables.py,sha256=w4IZftSlrbt-BMPjldULT_616LSiNE3h7GmrFF7K5OM,2276
|
|
4
|
-
table_processor/commands/merge_tables.py,sha256=
|
|
5
|
-
table_processor/core/actions.py,sha256=
|
|
4
|
+
table_processor/commands/merge_tables.py,sha256=GHz3uBj_yeQzBr1_2b2ua8EUr0_B3_M-33CSdTD_wUc,1974
|
|
5
|
+
table_processor/core/actions.py,sha256=BNXf9iptGl9xV2itNK4bVx1jjVHCiRgTIFlZyULe6Dc,23695
|
|
6
6
|
table_processor/core/config.py,sha256=Z1s2r3y4oQXdbDCwIY_hYzoq6VRv7Sb3oUlfBCu13Lc,11646
|
|
7
7
|
table_processor/core/constants.py,sha256=w-1TxtpXywb6Qh8M4YWuzcCHUvCjy5zJYxaXC3RQS6A,158
|
|
8
8
|
table_processor/core/convert.py,sha256=dzGcpBwJ5omiE8Pw-VmHnGoOqDyh1Rip6BiLdvdf3V8,11561
|
|
@@ -14,10 +14,10 @@ table_processor/core/functions/search_column_value.py,sha256=GscwLaMTORHFDhdCdjz
|
|
|
14
14
|
table_processor/core/functions/set_flat_field_value.py,sha256=7-BgD2yEUGyBaFaIJ18bYv82Qdy0CN8NiC5ZtsAdv44,531
|
|
15
15
|
table_processor/core/functions/set_nested_field_value.py,sha256=351AoyL8-dT9I4eBKYlxUME03ACiMjDukebzmhOBaks,1308
|
|
16
16
|
table_processor/core/functions/set_row_value.py,sha256=wlF_nVGZY74XCzd6pBJJyti62m6y0s1kc5Q6uq9jn8o,641
|
|
17
|
-
table_processor/core/merge.py,sha256=
|
|
17
|
+
table_processor/core/merge.py,sha256=mP-DR7Hb6RJcqXEyEgk33AWUYlOgdcvLVYY-IsMKr9A,5361
|
|
18
18
|
table_processor/core/types.py,sha256=xNvy1vL1ei87kt-MgSfRJSllYrNKRo23pHtJA15DyLQ,2895
|
|
19
|
-
python_table_processor-0.3.
|
|
20
|
-
python_table_processor-0.3.
|
|
21
|
-
python_table_processor-0.3.
|
|
22
|
-
python_table_processor-0.3.
|
|
23
|
-
python_table_processor-0.3.
|
|
19
|
+
python_table_processor-0.3.9.dist-info/LICENSE,sha256=1_Gn0I1neLPxDLfLiHEyxjDg-pbAra1p2iHEqutGS_c,1068
|
|
20
|
+
python_table_processor-0.3.9.dist-info/METADATA,sha256=RsoTUywEZBrBs1_XiEJO05LVNHHJaEnxVyzekwfLC_0,1098
|
|
21
|
+
python_table_processor-0.3.9.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
22
|
+
python_table_processor-0.3.9.dist-info/entry_points.txt,sha256=lq97F6m51yZ93qmVIqkUHJfbILZuYLxrMWXSqrP4JpM,118
|
|
23
|
+
python_table_processor-0.3.9.dist-info/RECORD,,
|
table_processor/__init__.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = "0.3.
|
|
2
|
-
__version_tuple__ = (0, 3,
|
|
1
|
+
__version__ = "0.3.9"
|
|
2
|
+
__version_tuple__ = (0, 3, 9)
|
|
@@ -17,6 +17,7 @@ def run(
|
|
|
17
17
|
ignore_not_found=args.ignore_not_found,
|
|
18
18
|
output_base_data_file=args.output_base_data_file,
|
|
19
19
|
output_modified_data_file=args.output_modified_data_file,
|
|
20
|
+
output_remaining_data_file=args.output_remaining_data_file,
|
|
20
21
|
)
|
|
21
22
|
|
|
22
23
|
def setup_parser(
|
|
@@ -60,4 +61,9 @@ def setup_parser(
|
|
|
60
61
|
required=False,
|
|
61
62
|
help='Path to output modified data file',
|
|
62
63
|
)
|
|
64
|
+
parser.add_argument(
|
|
65
|
+
'--output-remaining-data-file', '--output-remaining', '--output-remain',
|
|
66
|
+
required=False,
|
|
67
|
+
help='Path to output remaining data file',
|
|
68
|
+
)
|
|
63
69
|
parser.set_defaults(handler=run)
|
table_processor/core/actions.py
CHANGED
|
@@ -486,9 +486,9 @@ def search_with_operator(
|
|
|
486
486
|
row: Row,
|
|
487
487
|
source: str,
|
|
488
488
|
):
|
|
489
|
-
or_operator = '
|
|
490
|
-
null_or_operator = '
|
|
491
|
-
operator_group = f'{or_operator}|{null_or_operator}'
|
|
489
|
+
or_operator = '||'
|
|
490
|
+
null_or_operator = '??'
|
|
491
|
+
operator_group = f'{re.escape(or_operator)}|{re.escape(null_or_operator)}'
|
|
492
492
|
matched = re.split(f'({operator_group})', source, 1)
|
|
493
493
|
#ic(source, matched)
|
|
494
494
|
if len(matched) == 1:
|
|
@@ -496,10 +496,10 @@ def search_with_operator(
|
|
|
496
496
|
matched = map(str.strip, matched)
|
|
497
497
|
left, operator, rest = matched
|
|
498
498
|
value, found = search_column_value(row.nested, left)
|
|
499
|
-
if operator ==
|
|
499
|
+
if operator == or_operator:
|
|
500
500
|
if bool(value):
|
|
501
501
|
return value, found
|
|
502
|
-
if operator ==
|
|
502
|
+
if operator == null_or_operator:
|
|
503
503
|
if found and value is not None:
|
|
504
504
|
return value, found
|
|
505
505
|
return search_with_operator(row, rest)
|
table_processor/core/merge.py
CHANGED
|
@@ -39,6 +39,19 @@ from . convert import (
|
|
|
39
39
|
save,
|
|
40
40
|
)
|
|
41
41
|
|
|
42
|
+
def get_primary_key(
|
|
43
|
+
row: Mapping,
|
|
44
|
+
keys: list[str],
|
|
45
|
+
):
|
|
46
|
+
list_keys = []
|
|
47
|
+
for key in keys:
|
|
48
|
+
value, found = search_column_value(row, key)
|
|
49
|
+
if not found:
|
|
50
|
+
raise KeyError(f'Column not found: {key}, existing columns: {row.keys()}')
|
|
51
|
+
list_keys.append(value)
|
|
52
|
+
primary_key = tuple(list_keys)
|
|
53
|
+
return primary_key
|
|
54
|
+
|
|
42
55
|
def merge(
|
|
43
56
|
previous_files: list[str],
|
|
44
57
|
modification_files: list[str],
|
|
@@ -47,13 +60,16 @@ def merge(
|
|
|
47
60
|
ignore_not_found: bool = False,
|
|
48
61
|
output_base_data_file: str | None = None,
|
|
49
62
|
output_modified_data_file: str | None = None,
|
|
63
|
+
output_remaining_data_file: str | None = None,
|
|
50
64
|
):
|
|
51
65
|
ic.enable()
|
|
52
66
|
ic()
|
|
53
67
|
ic(previous_files)
|
|
54
68
|
ic(modification_files)
|
|
55
69
|
ic(keys)
|
|
56
|
-
dict_key_to_row = {}
|
|
70
|
+
#dict_key_to_row = {}
|
|
71
|
+
dict_key_to_row = OrderedDict()
|
|
72
|
+
set_modified_keys = set()
|
|
57
73
|
all_base_rows = []
|
|
58
74
|
all_modified_rows = []
|
|
59
75
|
list_ignored_keys = []
|
|
@@ -74,13 +90,7 @@ def merge(
|
|
|
74
90
|
total=len(df),
|
|
75
91
|
):
|
|
76
92
|
row = prepare_row(flat_row)
|
|
77
|
-
|
|
78
|
-
for key in keys:
|
|
79
|
-
value, found = search_column_value(row.nested, key)
|
|
80
|
-
if not found:
|
|
81
|
-
raise KeyError(f'Column not found: {key}, existing columns: {row.flat.keys()}')
|
|
82
|
-
list_keys.append(value)
|
|
83
|
-
primary_key = tuple(list_keys)
|
|
93
|
+
primary_key = get_primary_key(row.flat, keys)
|
|
84
94
|
#ic(key)
|
|
85
95
|
if not allow_duplicate_keys:
|
|
86
96
|
if primary_key in dict_key_to_row:
|
|
@@ -104,13 +114,7 @@ def merge(
|
|
|
104
114
|
total=len(df),
|
|
105
115
|
):
|
|
106
116
|
row = prepare_row(flat_row)
|
|
107
|
-
|
|
108
|
-
for key in keys:
|
|
109
|
-
value, found = search_column_value(row.nested, key)
|
|
110
|
-
if not found:
|
|
111
|
-
raise KeyError(f'Column not found: {key}, existing columns: {row.flat.keys()}')
|
|
112
|
-
list_keys.append(value)
|
|
113
|
-
primary_key = tuple(list_keys)
|
|
117
|
+
primary_key = get_primary_key(row.flat, keys)
|
|
114
118
|
#ic(key)
|
|
115
119
|
#if key not in dict_key_to_row:
|
|
116
120
|
# dict_key_to_row[key] = row
|
|
@@ -137,6 +141,7 @@ def merge(
|
|
|
137
141
|
#ic(previous_row)
|
|
138
142
|
#ic(previous_row.flat)
|
|
139
143
|
#raise
|
|
144
|
+
set_modified_keys.add(primary_key)
|
|
140
145
|
num_modified += 1
|
|
141
146
|
ic(num_modified)
|
|
142
147
|
if ignore_not_found:
|
|
@@ -150,3 +155,11 @@ def merge(
|
|
|
150
155
|
all_df = pd.DataFrame([row.flat for row in all_modified_rows])
|
|
151
156
|
ic('Saving to: ', output_modified_data_file)
|
|
152
157
|
save(all_df, output_modified_data_file)
|
|
158
|
+
if output_remaining_data_file:
|
|
159
|
+
remaining_rows = []
|
|
160
|
+
for key, row in dict_key_to_row.items():
|
|
161
|
+
if key not in set_modified_keys:
|
|
162
|
+
remaining_rows.append(row)
|
|
163
|
+
all_df = pd.DataFrame([row.flat for row in remaining_rows])
|
|
164
|
+
ic('Saving to: ', output_remaining_data_file)
|
|
165
|
+
save(all_df, output_remaining_data_file)
|
|
File without changes
|
|
File without changes
|
{python_table_processor-0.3.7.dist-info → python_table_processor-0.3.9.dist-info}/entry_points.txt
RENAMED
|
File without changes
|