python-table-converter 0.2.5__tar.gz → 0.2.7__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_converter-0.2.5 → python_table_converter-0.2.7}/PKG-INFO +1 -1
- {python_table_converter-0.2.5 → python_table_converter-0.2.7}/pyproject.toml +1 -1
- python_table_converter-0.2.7/table_converter/__init__.py +2 -0
- {python_table_converter-0.2.5 → python_table_converter-0.2.7}/table_converter/cli.py +4 -0
- {python_table_converter-0.2.5 → python_table_converter-0.2.7}/table_converter/commands/convert_tables.py +0 -4
- python_table_converter-0.2.7/table_converter/core/constants.py +3 -0
- {python_table_converter-0.2.5 → python_table_converter-0.2.7}/table_converter/core/convert.py +18 -13
- {python_table_converter-0.2.5 → python_table_converter-0.2.7}/table_converter/core/functions/search_column_value.py +6 -4
- python_table_converter-0.2.5/table_converter/__init__.py +0 -2
- {python_table_converter-0.2.5 → python_table_converter-0.2.7}/LICENSE +0 -0
- {python_table_converter-0.2.5 → python_table_converter-0.2.7}/README.md +0 -0
- {python_table_converter-0.2.5 → python_table_converter-0.2.7}/table_converter/core/config.py +0 -0
- {python_table_converter-0.2.5 → python_table_converter-0.2.7}/table_converter/core/functions/assign_id.py +0 -0
- {python_table_converter-0.2.5 → python_table_converter-0.2.7}/table_converter/core/functions/get_field_value.py +0 -0
- {python_table_converter-0.2.5 → python_table_converter-0.2.7}/table_converter/core/functions/set_field_value.py +0 -0
|
@@ -41,6 +41,10 @@ def command_convert_tables(
|
|
|
41
41
|
|
|
42
42
|
def main():
|
|
43
43
|
parser = argparse.ArgumentParser(description='Table Data Converter')
|
|
44
|
+
parser.add_argument(
|
|
45
|
+
'--verbose', '-v',
|
|
46
|
+
action='store_true',
|
|
47
|
+
)
|
|
44
48
|
parser.set_defaults(handler=None)
|
|
45
49
|
subparsers = parser.add_subparsers(dest='command')
|
|
46
50
|
|
{python_table_converter-0.2.5 → python_table_converter-0.2.7}/table_converter/core/convert.py
RENAMED
|
@@ -14,6 +14,11 @@ import pandas as pd
|
|
|
14
14
|
# local
|
|
15
15
|
|
|
16
16
|
from . config import setup_config
|
|
17
|
+
from . constants import (
|
|
18
|
+
FILE_FIELD,
|
|
19
|
+
INPUT_FIELD,
|
|
20
|
+
STAGING_FIELD,
|
|
21
|
+
)
|
|
17
22
|
from . functions.assign_id import (
|
|
18
23
|
assign_id,
|
|
19
24
|
create_id_context_map,
|
|
@@ -96,12 +101,12 @@ def search_column_value(
|
|
|
96
101
|
row: OrderedDict,
|
|
97
102
|
column: str,
|
|
98
103
|
):
|
|
99
|
-
if
|
|
100
|
-
value, found = get_field_value(row[
|
|
104
|
+
if STAGING_FIELD in row:
|
|
105
|
+
value, found = get_field_value(row[STAGING_FIELD], column)
|
|
101
106
|
if found:
|
|
102
107
|
return value, True
|
|
103
|
-
value, found = get_field_value(row[
|
|
104
|
-
original, found = get_field_value(row, '
|
|
108
|
+
value, found = get_field_value(row[STAGING_FIELD], column)
|
|
109
|
+
original, found = get_field_value(row, f'{STAGING_FIELD}.{INPUT_FIELD}')
|
|
105
110
|
if found:
|
|
106
111
|
value, found = get_field_value(original, column)
|
|
107
112
|
if found:
|
|
@@ -119,7 +124,7 @@ def map_constants(
|
|
|
119
124
|
new_row = OrderedDict(row)
|
|
120
125
|
for column in dict_constants.keys():
|
|
121
126
|
#set_field_value(new_row, column, dict_constants[column])
|
|
122
|
-
set_field_value(new_row, f'
|
|
127
|
+
set_field_value(new_row, f'{STAGING_FIELD}.{column}', dict_constants[column])
|
|
123
128
|
return new_row
|
|
124
129
|
|
|
125
130
|
def map_formats(
|
|
@@ -130,7 +135,7 @@ def map_formats(
|
|
|
130
135
|
for column in dict_formats.keys():
|
|
131
136
|
template = dict_formats[column]
|
|
132
137
|
params = {}
|
|
133
|
-
params.update(row[
|
|
138
|
+
params.update(row[STAGING_FIELD])
|
|
134
139
|
params.update(row)
|
|
135
140
|
formatted = None
|
|
136
141
|
while formatted is None:
|
|
@@ -144,7 +149,7 @@ def map_formats(
|
|
|
144
149
|
params[key] = f'__{key}__undefined__'
|
|
145
150
|
except:
|
|
146
151
|
raise
|
|
147
|
-
set_field_value(new_row, f'
|
|
152
|
+
set_field_value(new_row, f'{STAGING_FIELD}.{column}', formatted)
|
|
148
153
|
return new_row
|
|
149
154
|
|
|
150
155
|
def remap_columns(
|
|
@@ -157,7 +162,7 @@ def remap_columns(
|
|
|
157
162
|
if found:
|
|
158
163
|
set_field_value(new_row, column, value)
|
|
159
164
|
for column in row.keys():
|
|
160
|
-
if column ==
|
|
165
|
+
if column == STAGING_FIELD:
|
|
161
166
|
# NOTE: Ignore debug fields
|
|
162
167
|
set_field_value(new_row, column, row[column])
|
|
163
168
|
return new_row
|
|
@@ -173,9 +178,9 @@ def apply_fields_split_by_newline(
|
|
|
173
178
|
if found:
|
|
174
179
|
if isinstance(value, str):
|
|
175
180
|
new_value = value.split('\n')
|
|
176
|
-
set_field_value(new_row, f'
|
|
181
|
+
set_field_value(new_row, f'{STAGING_FIELD}.{column}', new_value)
|
|
177
182
|
else:
|
|
178
|
-
set_field_value(new_row, f'
|
|
183
|
+
set_field_value(new_row, f'{STAGING_FIELD}.{column}', value)
|
|
179
184
|
return new_row
|
|
180
185
|
|
|
181
186
|
def convert(
|
|
@@ -256,8 +261,8 @@ def convert(
|
|
|
256
261
|
for index, row in df.iterrows():
|
|
257
262
|
orig = OrderedDict(row)
|
|
258
263
|
new_row = OrderedDict(row)
|
|
259
|
-
set_field_value(new_row, '
|
|
260
|
-
set_field_value(new_row, '
|
|
264
|
+
set_field_value(new_row, f'{STAGING_FIELD}.{INPUT_FIELD}', orig)
|
|
265
|
+
set_field_value(new_row, f'{STAGING_FIELD}.{FILE_FIELD}', input_file)
|
|
261
266
|
if config.process.assign_constants:
|
|
262
267
|
new_row = map_constants(new_row, config.process.assign_constants)
|
|
263
268
|
if config.map:
|
|
@@ -271,7 +276,7 @@ def convert(
|
|
|
271
276
|
if config.map:
|
|
272
277
|
new_row = remap_columns(new_row, config.map)
|
|
273
278
|
if not output_debug:
|
|
274
|
-
new_row.pop(
|
|
279
|
+
new_row.pop(STAGING_FIELD, None)
|
|
275
280
|
new_rows.append(new_row)
|
|
276
281
|
new_df = pd.DataFrame(new_rows)
|
|
277
282
|
df_list.append(new_df)
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
This function is used to search for a column value in a row. It will first search in the '__debug__' field, then in the '__debug__.__original__' field, and finally in the row itself. If the value is found, it will be set in the row and returned.
|
|
3
3
|
'''
|
|
4
4
|
|
|
5
|
+
from .. constants import STAGING_FIELD
|
|
6
|
+
|
|
5
7
|
from collections import OrderedDict
|
|
6
8
|
|
|
7
9
|
from . get_field_value import get_field_value
|
|
@@ -11,12 +13,12 @@ def search_column_value(
|
|
|
11
13
|
row: OrderedDict,
|
|
12
14
|
column: str,
|
|
13
15
|
):
|
|
14
|
-
if
|
|
15
|
-
value, found = get_field_value(row[
|
|
16
|
+
if STAGING_FIELD in row:
|
|
17
|
+
value, found = get_field_value(row[STAGING_FIELD], column)
|
|
16
18
|
if found:
|
|
17
19
|
return value, True
|
|
18
|
-
value, found = get_field_value(row[
|
|
19
|
-
original, found = get_field_value(row, '
|
|
20
|
+
value, found = get_field_value(row[STAGING_FIELD], column)
|
|
21
|
+
original, found = get_field_value(row, f'{STAGING_FIELD}.__original__')
|
|
20
22
|
if found:
|
|
21
23
|
value, found = get_field_value(original, column)
|
|
22
24
|
if found:
|
|
File without changes
|
|
File without changes
|
{python_table_converter-0.2.5 → python_table_converter-0.2.7}/table_converter/core/config.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|