python-table-converter 0.2.7__tar.gz → 0.2.8__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.7 → python_table_converter-0.2.8}/PKG-INFO +1 -1
- {python_table_converter-0.2.7 → python_table_converter-0.2.8}/pyproject.toml +1 -1
- python_table_converter-0.2.8/table_converter/__init__.py +2 -0
- {python_table_converter-0.2.7 → python_table_converter-0.2.8}/table_converter/cli.py +8 -2
- {python_table_converter-0.2.7 → python_table_converter-0.2.8}/table_converter/core/convert.py +12 -2
- python_table_converter-0.2.7/table_converter/__init__.py +0 -2
- {python_table_converter-0.2.7 → python_table_converter-0.2.8}/LICENSE +0 -0
- {python_table_converter-0.2.7 → python_table_converter-0.2.8}/README.md +0 -0
- {python_table_converter-0.2.7 → python_table_converter-0.2.8}/table_converter/commands/convert_tables.py +0 -0
- {python_table_converter-0.2.7 → python_table_converter-0.2.8}/table_converter/core/config.py +0 -0
- {python_table_converter-0.2.7 → python_table_converter-0.2.8}/table_converter/core/constants.py +0 -0
- {python_table_converter-0.2.7 → python_table_converter-0.2.8}/table_converter/core/functions/assign_id.py +0 -0
- {python_table_converter-0.2.7 → python_table_converter-0.2.8}/table_converter/core/functions/get_field_value.py +0 -0
- {python_table_converter-0.2.7 → python_table_converter-0.2.8}/table_converter/core/functions/search_column_value.py +0 -0
- {python_table_converter-0.2.7 → python_table_converter-0.2.8}/table_converter/core/functions/set_field_value.py +0 -0
|
@@ -39,12 +39,17 @@ def command_convert_tables(
|
|
|
39
39
|
if parser is None:
|
|
40
40
|
parse_and_run(command_parser)
|
|
41
41
|
|
|
42
|
-
def
|
|
43
|
-
parser
|
|
42
|
+
def setup_common_args(
|
|
43
|
+
parser: argparse.ArgumentParser,
|
|
44
|
+
):
|
|
44
45
|
parser.add_argument(
|
|
45
46
|
'--verbose', '-v',
|
|
46
47
|
action='store_true',
|
|
47
48
|
)
|
|
49
|
+
|
|
50
|
+
def main():
|
|
51
|
+
parser = argparse.ArgumentParser(description='Table Data Converter')
|
|
52
|
+
setup_common_args(parser)
|
|
48
53
|
parser.set_defaults(handler=None)
|
|
49
54
|
subparsers = parser.add_subparsers(dest='command')
|
|
50
55
|
|
|
@@ -52,6 +57,7 @@ def main():
|
|
|
52
57
|
'convert',
|
|
53
58
|
help='Convert a table to a different format.'
|
|
54
59
|
)
|
|
60
|
+
setup_common_args(parser_convert_tables)
|
|
55
61
|
command_convert_tables(parser_convert_tables)
|
|
56
62
|
|
|
57
63
|
parse_and_run(parser)
|
{python_table_converter-0.2.7 → python_table_converter-0.2.8}/table_converter/core/convert.py
RENAMED
|
@@ -52,6 +52,15 @@ def load_excel(
|
|
|
52
52
|
df = pd.read_excel(input_file)
|
|
53
53
|
return df
|
|
54
54
|
|
|
55
|
+
@register_loader('.json')
|
|
56
|
+
def load_json(
|
|
57
|
+
input_file: str,
|
|
58
|
+
):
|
|
59
|
+
with open(input_file, 'r') as f:
|
|
60
|
+
data = json.load(f)
|
|
61
|
+
df = pd.DataFrame(data)
|
|
62
|
+
return df
|
|
63
|
+
|
|
55
64
|
@register_saver('.json')
|
|
56
65
|
def save_json(
|
|
57
66
|
df: pd.DataFrame,
|
|
@@ -261,8 +270,9 @@ def convert(
|
|
|
261
270
|
for index, row in df.iterrows():
|
|
262
271
|
orig = OrderedDict(row)
|
|
263
272
|
new_row = OrderedDict(row)
|
|
264
|
-
|
|
265
|
-
|
|
273
|
+
if STAGING_FIELD not in new_row:
|
|
274
|
+
set_field_value(new_row, f'{STAGING_FIELD}.{INPUT_FIELD}', orig)
|
|
275
|
+
set_field_value(new_row, f'{STAGING_FIELD}.{FILE_FIELD}', input_file)
|
|
266
276
|
if config.process.assign_constants:
|
|
267
277
|
new_row = map_constants(new_row, config.process.assign_constants)
|
|
268
278
|
if config.map:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_table_converter-0.2.7 → python_table_converter-0.2.8}/table_converter/core/config.py
RENAMED
|
File without changes
|
{python_table_converter-0.2.7 → python_table_converter-0.2.8}/table_converter/core/constants.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|