python-table-processor 0.3.9__py3-none-any.whl → 0.3.11__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-table-processor
3
- Version: 0.3.9
3
+ Version: 0.3.11
4
4
  Summary: A table data processor
5
5
  Home-page: https://github.com/akivajp/python-table-processor
6
6
  License: MIT
@@ -1,11 +1,11 @@
1
- table_processor/__init__.py,sha256=sA4b5QjPy1l9_d8B5UqNxW9ElcTD5ccsduZThd_EcI0,52
1
+ table_processor/__init__.py,sha256=VGVBf0Tvu9kKvvklW4UI-fweoMZobinpwjqSjD7Hm30,54
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=GHz3uBj_yeQzBr1_2b2ua8EUr0_B3_M-33CSdTD_wUc,1974
5
- table_processor/core/actions.py,sha256=BNXf9iptGl9xV2itNK4bVx1jjVHCiRgTIFlZyULe6Dc,23695
4
+ table_processor/commands/merge_tables.py,sha256=fIk3e-Qbdj3QtOXetC4ItbJs9NfBHVsraRhdfnpy2RQ,2194
5
+ table_processor/core/actions.py,sha256=3yjSW1CKXPn49BNHx0HbjkU5gp8266s5iun57snXqlc,23815
6
6
  table_processor/core/config.py,sha256=Z1s2r3y4oQXdbDCwIY_hYzoq6VRv7Sb3oUlfBCu13Lc,11646
7
7
  table_processor/core/constants.py,sha256=w-1TxtpXywb6Qh8M4YWuzcCHUvCjy5zJYxaXC3RQS6A,158
8
- table_processor/core/convert.py,sha256=dzGcpBwJ5omiE8Pw-VmHnGoOqDyh1Rip6BiLdvdf3V8,11561
8
+ table_processor/core/convert.py,sha256=yF_ypp0WCdyavhLldP_dQE9aw9Bm5bS8DQgsCQTTT2E,11562
9
9
  table_processor/core/functions/assign_id.py,sha256=dA-wgZA7E01gbx8qGvo1PeMd3aq9PhMdyITzr3BKXIE,4204
10
10
  table_processor/core/functions/flatten_row.py,sha256=2l-s4YXgBM58IthpfVzd7L4EGUCekSi7ss5CaM_3MUU,686
11
11
  table_processor/core/functions/get_nested_field_value.py,sha256=ZEJi8XtDONoYmhPoqYpVZRGtEWvsfAksV4FXtkMAaq8,946
@@ -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=mP-DR7Hb6RJcqXEyEgk33AWUYlOgdcvLVYY-IsMKr9A,5361
18
- table_processor/core/types.py,sha256=xNvy1vL1ei87kt-MgSfRJSllYrNKRo23pHtJA15DyLQ,2895
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,,
17
+ table_processor/core/merge.py,sha256=gcMQ5LgBssGBZ0CuSPN0ddslNuLznxwh024kRiGOFLM,5800
18
+ table_processor/core/types.py,sha256=76Fn1PQgO03Swe7E_zFLjusbQ6w9sfxzsL08uHS21hE,2919
19
+ python_table_processor-0.3.11.dist-info/LICENSE,sha256=1_Gn0I1neLPxDLfLiHEyxjDg-pbAra1p2iHEqutGS_c,1068
20
+ python_table_processor-0.3.11.dist-info/METADATA,sha256=scfDAfEQ1Gm7-BmJgJEC_XeGzjGAP87OmyQV5aADoko,1099
21
+ python_table_processor-0.3.11.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
22
+ python_table_processor-0.3.11.dist-info/entry_points.txt,sha256=lq97F6m51yZ93qmVIqkUHJfbILZuYLxrMWXSqrP4JpM,118
23
+ python_table_processor-0.3.11.dist-info/RECORD,,
@@ -1,2 +1,2 @@
1
- __version__ = "0.3.9"
2
- __version_tuple__ = (0, 3, 9)
1
+ __version__ = "0.3.11"
2
+ __version_tuple__ = (0, 3, 11)
@@ -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)
@@ -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 f'{STAGING_FIELD}.{config.field}' not in row.flat:
611
- set_row_staging_value(row, config.field, value)
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(
@@ -391,7 +391,7 @@ def convert(
391
391
  #ic(all_df.columns)
392
392
  #ic(all_df.iloc[0])
393
393
  if output_file:
394
- ic('Saing to: ', output_file)
394
+ ic('Saving to: ', output_file)
395
395
  saver(all_df, output_file)
396
396
  else:
397
397
  ic(all_df)
@@ -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
- for key, value in row.flat.items():
136
- if key.startswith('__staging__.'):
137
- continue
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
- set_row_value(previous_row, key, value)
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)
@@ -80,6 +80,7 @@ class JoinConfig:
80
80
  @dataclasses.dataclass
81
81
  class OmitConfig:
82
82
  field: str
83
+ purge: bool = False
83
84
 
84
85
  @dataclasses.dataclass
85
86
  class ParseConfig: