python-table-processor 0.3.9__tar.gz → 0.3.11__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.
- {python_table_processor-0.3.9 → python_table_processor-0.3.11}/PKG-INFO +1 -1
- {python_table_processor-0.3.9 → python_table_processor-0.3.11}/pyproject.toml +1 -1
- python_table_processor-0.3.11/table_processor/__init__.py +2 -0
- {python_table_processor-0.3.9 → python_table_processor-0.3.11}/table_processor/commands/merge_tables.py +7 -0
- {python_table_processor-0.3.9 → python_table_processor-0.3.11}/table_processor/core/actions.py +5 -2
- {python_table_processor-0.3.9 → python_table_processor-0.3.11}/table_processor/core/convert.py +1 -1
- {python_table_processor-0.3.9 → python_table_processor-0.3.11}/table_processor/core/merge.py +14 -4
- {python_table_processor-0.3.9 → python_table_processor-0.3.11}/table_processor/core/types.py +1 -0
- python_table_processor-0.3.9/table_processor/__init__.py +0 -2
- {python_table_processor-0.3.9 → python_table_processor-0.3.11}/LICENSE +0 -0
- {python_table_processor-0.3.9 → python_table_processor-0.3.11}/README.md +0 -0
- {python_table_processor-0.3.9 → python_table_processor-0.3.11}/table_processor/cli.py +0 -0
- {python_table_processor-0.3.9 → python_table_processor-0.3.11}/table_processor/commands/convert_tables.py +0 -0
- {python_table_processor-0.3.9 → python_table_processor-0.3.11}/table_processor/core/config.py +0 -0
- {python_table_processor-0.3.9 → python_table_processor-0.3.11}/table_processor/core/constants.py +0 -0
- {python_table_processor-0.3.9 → python_table_processor-0.3.11}/table_processor/core/functions/assign_id.py +0 -0
- {python_table_processor-0.3.9 → python_table_processor-0.3.11}/table_processor/core/functions/flatten_row.py +0 -0
- {python_table_processor-0.3.9 → python_table_processor-0.3.11}/table_processor/core/functions/get_nested_field_value.py +0 -0
- {python_table_processor-0.3.9 → python_table_processor-0.3.11}/table_processor/core/functions/nest_row.py +0 -0
- {python_table_processor-0.3.9 → python_table_processor-0.3.11}/table_processor/core/functions/search_column_value.py +0 -0
- {python_table_processor-0.3.9 → python_table_processor-0.3.11}/table_processor/core/functions/set_flat_field_value.py +0 -0
- {python_table_processor-0.3.9 → python_table_processor-0.3.11}/table_processor/core/functions/set_nested_field_value.py +0 -0
- {python_table_processor-0.3.9 → python_table_processor-0.3.11}/table_processor/core/functions/set_row_value.py +0 -0
|
@@ -18,6 +18,7 @@ def run(
|
|
|
18
18
|
output_base_data_file=args.output_base_data_file,
|
|
19
19
|
output_modified_data_file=args.output_modified_data_file,
|
|
20
20
|
output_remaining_data_file=args.output_remaining_data_file,
|
|
21
|
+
merge_fields=args.merge_fields,
|
|
21
22
|
)
|
|
22
23
|
|
|
23
24
|
def setup_parser(
|
|
@@ -66,4 +67,10 @@ def setup_parser(
|
|
|
66
67
|
required=False,
|
|
67
68
|
help='Path to output remaining data file',
|
|
68
69
|
)
|
|
70
|
+
parser.add_argument(
|
|
71
|
+
'--merge-fields', '--merge-field', '--merge-keys', '--merge-key',
|
|
72
|
+
nargs='+',
|
|
73
|
+
required=False,
|
|
74
|
+
help='Fields to merge',
|
|
75
|
+
)
|
|
69
76
|
parser.set_defaults(handler=run)
|
{python_table_processor-0.3.9 → python_table_processor-0.3.11}/table_processor/core/actions.py
RENAMED
|
@@ -196,8 +196,10 @@ def setup_actions_with_args(
|
|
|
196
196
|
))
|
|
197
197
|
continue
|
|
198
198
|
if action_name == 'omit':
|
|
199
|
+
purge = options.get('purge', False)
|
|
199
200
|
config.actions.append(OmitConfig(
|
|
200
201
|
field = target,
|
|
202
|
+
purge = purge,
|
|
201
203
|
))
|
|
202
204
|
continue
|
|
203
205
|
if action_name == 'parse':
|
|
@@ -607,8 +609,9 @@ def omit_field(
|
|
|
607
609
|
value, found = pop_row_value(row, config.field)
|
|
608
610
|
if not found:
|
|
609
611
|
return row
|
|
610
|
-
if
|
|
611
|
-
|
|
612
|
+
if not config.purge:
|
|
613
|
+
if f'{STAGING_FIELD}.{config.field}' not in row.flat:
|
|
614
|
+
set_row_staging_value(row, config.field, value)
|
|
612
615
|
return row
|
|
613
616
|
|
|
614
617
|
def join_field(
|
{python_table_processor-0.3.9 → python_table_processor-0.3.11}/table_processor/core/merge.py
RENAMED
|
@@ -61,6 +61,7 @@ def merge(
|
|
|
61
61
|
output_base_data_file: str | None = None,
|
|
62
62
|
output_modified_data_file: str | None = None,
|
|
63
63
|
output_remaining_data_file: str | None = None,
|
|
64
|
+
merge_fields: list[str] | None = None,
|
|
64
65
|
):
|
|
65
66
|
ic.enable()
|
|
66
67
|
ic()
|
|
@@ -132,12 +133,18 @@ def merge(
|
|
|
132
133
|
all_modified_rows.append(previous_row)
|
|
133
134
|
#ic(previous_row)
|
|
134
135
|
#ic(previous_row.flat)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
if merge_fields is None:
|
|
137
|
+
merge_fields = []
|
|
138
|
+
for field in row.flat.keys():
|
|
139
|
+
if field.startswith('__staging__.'):
|
|
140
|
+
continue
|
|
141
|
+
merge_fields.append(field)
|
|
142
|
+
for field in merge_fields:
|
|
143
|
+
value, found = search_column_value(row.flat, field)
|
|
138
144
|
#ic(key)
|
|
139
145
|
#ic(key, value)
|
|
140
|
-
|
|
146
|
+
if found:
|
|
147
|
+
set_row_value(previous_row, field, value)
|
|
141
148
|
#ic(previous_row)
|
|
142
149
|
#ic(previous_row.flat)
|
|
143
150
|
#raise
|
|
@@ -152,6 +159,9 @@ def merge(
|
|
|
152
159
|
ic('Saving to: ', output_base_data_file)
|
|
153
160
|
save(all_df, output_base_data_file)
|
|
154
161
|
if output_modified_data_file:
|
|
162
|
+
#all_modified_rows = []
|
|
163
|
+
#for key in set_modified_keys:
|
|
164
|
+
# all_modified_rows.append(dict_key_to_row[key])
|
|
155
165
|
all_df = pd.DataFrame([row.flat for row in all_modified_rows])
|
|
156
166
|
ic('Saving to: ', output_modified_data_file)
|
|
157
167
|
save(all_df, output_modified_data_file)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_table_processor-0.3.9 → python_table_processor-0.3.11}/table_processor/core/config.py
RENAMED
|
File without changes
|
{python_table_processor-0.3.9 → python_table_processor-0.3.11}/table_processor/core/constants.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|