python-table-processor 0.3.0__tar.gz → 0.3.1__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.0 → python_table_processor-0.3.1}/PKG-INFO +1 -1
- {python_table_processor-0.3.0 → python_table_processor-0.3.1}/pyproject.toml +1 -1
- python_table_processor-0.3.1/table_processor/__init__.py +2 -0
- {python_table_processor-0.3.0 → python_table_processor-0.3.1}/table_processor/core/actions.py +33 -0
- {python_table_processor-0.3.0 → python_table_processor-0.3.1}/table_processor/core/config.py +0 -7
- {python_table_processor-0.3.0 → python_table_processor-0.3.1}/table_processor/core/convert.py +0 -25
- {python_table_processor-0.3.0 → python_table_processor-0.3.1}/table_processor/core/types.py +6 -0
- python_table_processor-0.3.0/table_processor/__init__.py +0 -2
- {python_table_processor-0.3.0 → python_table_processor-0.3.1}/LICENSE +0 -0
- {python_table_processor-0.3.0 → python_table_processor-0.3.1}/README.md +0 -0
- {python_table_processor-0.3.0 → python_table_processor-0.3.1}/table_processor/cli.py +0 -0
- {python_table_processor-0.3.0 → python_table_processor-0.3.1}/table_processor/commands/convert_tables.py +0 -0
- {python_table_processor-0.3.0 → python_table_processor-0.3.1}/table_processor/commands/merge_tables.py +0 -0
- {python_table_processor-0.3.0 → python_table_processor-0.3.1}/table_processor/core/constants.py +0 -0
- {python_table_processor-0.3.0 → python_table_processor-0.3.1}/table_processor/core/functions/assign_id.py +0 -0
- {python_table_processor-0.3.0 → python_table_processor-0.3.1}/table_processor/core/functions/flatten_row.py +0 -0
- {python_table_processor-0.3.0 → python_table_processor-0.3.1}/table_processor/core/functions/get_nested_field_value.py +0 -0
- {python_table_processor-0.3.0 → python_table_processor-0.3.1}/table_processor/core/functions/nest_row.py +0 -0
- {python_table_processor-0.3.0 → python_table_processor-0.3.1}/table_processor/core/functions/search_column_value.py +0 -0
- {python_table_processor-0.3.0 → python_table_processor-0.3.1}/table_processor/core/functions/set_flat_field_value.py +0 -0
- {python_table_processor-0.3.0 → python_table_processor-0.3.1}/table_processor/core/functions/set_nested_field_value.py +0 -0
- {python_table_processor-0.3.0 → python_table_processor-0.3.1}/table_processor/core/functions/set_row_value.py +0 -0
- {python_table_processor-0.3.0 → python_table_processor-0.3.1}/table_processor/core/merge.py +0 -0
{python_table_processor-0.3.0 → python_table_processor-0.3.1}/table_processor/core/actions.py
RENAMED
|
@@ -34,6 +34,7 @@ from . types import (
|
|
|
34
34
|
OmitConfig,
|
|
35
35
|
ParseConfig,
|
|
36
36
|
PickConfig,
|
|
37
|
+
PushConfig,
|
|
37
38
|
SplitConfig,
|
|
38
39
|
Row,
|
|
39
40
|
)
|
|
@@ -189,6 +190,14 @@ def setup_actions_with_args(
|
|
|
189
190
|
required = required,
|
|
190
191
|
))
|
|
191
192
|
continue
|
|
193
|
+
if action_name == 'push':
|
|
194
|
+
condition = options.get('condition', None)
|
|
195
|
+
config.actions.append(PushConfig(
|
|
196
|
+
target = target,
|
|
197
|
+
source = source,
|
|
198
|
+
condition = condition,
|
|
199
|
+
))
|
|
200
|
+
continue
|
|
192
201
|
if action_name == 'split':
|
|
193
202
|
delimiter = options.get('delimiter', None)
|
|
194
203
|
if delimiter == '\\n':
|
|
@@ -304,6 +313,8 @@ def do_action(
|
|
|
304
313
|
return parse(row, action)
|
|
305
314
|
if isinstance(action, OmitConfig):
|
|
306
315
|
return omit_field(row, action)
|
|
316
|
+
if isinstance(action, PushConfig):
|
|
317
|
+
return push_field(row, action)
|
|
307
318
|
if isinstance(action, SplitConfig):
|
|
308
319
|
return split_field(row, action)
|
|
309
320
|
raise ValueError(
|
|
@@ -602,3 +613,25 @@ def parse(
|
|
|
602
613
|
parsed = value
|
|
603
614
|
set_row_staging_value(row, config.target, parsed)
|
|
604
615
|
return row
|
|
616
|
+
|
|
617
|
+
def push_field(
|
|
618
|
+
row: Row,
|
|
619
|
+
config: PushConfig,
|
|
620
|
+
):
|
|
621
|
+
source_value, found = search_column_value(row.nested, config.source)
|
|
622
|
+
do_append = False
|
|
623
|
+
if config.condition is None:
|
|
624
|
+
do_append = True
|
|
625
|
+
else:
|
|
626
|
+
condition_value, found = search_column_value(row.nested, config.condition)
|
|
627
|
+
if condition_value:
|
|
628
|
+
do_append = True
|
|
629
|
+
if do_append:
|
|
630
|
+
target_value, found = search_column_value(row.nested, config.target)
|
|
631
|
+
if found:
|
|
632
|
+
array = target_value
|
|
633
|
+
else:
|
|
634
|
+
array = []
|
|
635
|
+
set_row_staging_value(row, config.target, array)
|
|
636
|
+
array.append(source_value)
|
|
637
|
+
return row
|
{python_table_processor-0.3.0 → python_table_processor-0.3.1}/table_processor/core/config.py
RENAMED
|
@@ -31,17 +31,10 @@ class AssignArrayConfig:
|
|
|
31
31
|
field: str
|
|
32
32
|
optional: bool = True
|
|
33
33
|
|
|
34
|
-
@dataclasses.dataclass
|
|
35
|
-
class PushConfig:
|
|
36
|
-
target: str
|
|
37
|
-
source: str
|
|
38
|
-
condition: str | None = None
|
|
39
|
-
|
|
40
34
|
@dataclasses.dataclass
|
|
41
35
|
class ProcessConfig:
|
|
42
36
|
assign_array: Mapping[str, list[AssignArrayConfig]] = dataclasses.field(default_factory=OrderedDict)
|
|
43
37
|
assign_length: FlatFieldMap = dataclasses.field(default_factory=OrderedDict)
|
|
44
|
-
push: list[PushConfig] = dataclasses.field(default_factory=list)
|
|
45
38
|
|
|
46
39
|
def __setitem__(self, key, value):
|
|
47
40
|
setattr(self, key, value)
|
{python_table_processor-0.3.0 → python_table_processor-0.3.1}/table_processor/core/convert.py
RENAMED
|
@@ -20,7 +20,6 @@ import pandas as pd
|
|
|
20
20
|
|
|
21
21
|
from . config import (
|
|
22
22
|
AssignArrayConfig,
|
|
23
|
-
PushConfig,
|
|
24
23
|
setup_config,
|
|
25
24
|
setup_pick_with_args,
|
|
26
25
|
)
|
|
@@ -264,28 +263,6 @@ def search_column_value_from_nested(
|
|
|
264
263
|
return None, False
|
|
265
264
|
|
|
266
265
|
|
|
267
|
-
def push_fields(
|
|
268
|
-
row: OrderedDict,
|
|
269
|
-
list_config: list[PushConfig],
|
|
270
|
-
):
|
|
271
|
-
nested_row = nest(row)
|
|
272
|
-
for config in list_config:
|
|
273
|
-
target_value, found = search_column_value_from_nested(nested_row, config.target)
|
|
274
|
-
if found:
|
|
275
|
-
array = target_value
|
|
276
|
-
else:
|
|
277
|
-
array = []
|
|
278
|
-
#set_field_value(nested_row, f'{STAGING_FIELD}.{config.target}', array)
|
|
279
|
-
set_row_staging_value(nested_row, config.target, array)
|
|
280
|
-
source_value, found = search_column_value_from_nested(nested_row, config.source)
|
|
281
|
-
if config.condition is None:
|
|
282
|
-
array.append(source_value)
|
|
283
|
-
continue
|
|
284
|
-
condition_value, found = search_column_value_from_nested(nested_row, config.condition)
|
|
285
|
-
if condition_value:
|
|
286
|
-
array.append(source_value)
|
|
287
|
-
return flatten_row(nested_row)
|
|
288
|
-
|
|
289
266
|
def assign_length(
|
|
290
267
|
row: OrderedDict,
|
|
291
268
|
dict_fields: OrderedDict,
|
|
@@ -371,8 +348,6 @@ def convert(
|
|
|
371
348
|
set_row_staging_value(row, INPUT_FIELD, orig_row.nested)
|
|
372
349
|
if config.process.assign_array:
|
|
373
350
|
row.flat= assign_array(row.flat, config.process.assign_array)
|
|
374
|
-
if config.process.push:
|
|
375
|
-
row.flat = push_fields(row.flat, config.process.push)
|
|
376
351
|
if config.process.assign_length:
|
|
377
352
|
row.flat = assign_length(row.flat, config.process.assign_length)
|
|
378
353
|
if config.actions:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_table_processor-0.3.0 → python_table_processor-0.3.1}/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
|
|
File without changes
|