python-table-processor 0.2.29__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Akiva Miura
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.1
2
+ Name: python-table-processor
3
+ Version: 0.2.29
4
+ Summary: A table data processor
5
+ Home-page: https://github.com/akivajp/python-table-processor
6
+ License: MIT
7
+ Author: Akiva Miura
8
+ Author-email: akiva.miura@gmail.com
9
+ Requires-Python: >=3.10,<4.0
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Requires-Dist: icecream (>=2.1.3,<3.0.0)
16
+ Requires-Dist: logzero (>=1.7.0,<2.0.0)
17
+ Requires-Dist: openpyxl (>=3.1.5,<4.0.0)
18
+ Requires-Dist: pandas (>=2.2.3,<3.0.0)
19
+ Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
20
+ Requires-Dist: tqdm (>=4.67.0,<5.0.0)
21
+ Requires-Dist: xlsxwriter (>=3.2.0,<4.0.0)
22
+ Project-URL: Repository, https://github.com/akivajp/python-table-processor
23
+ Description-Content-Type: text/markdown
24
+
25
+ # Table Data Converter
26
+
27
+ This is a python-based tool that converts tables from one format to another. It can convert tables from CSV, TSV, Excel, JSON, and JSON Lines to any of these formats.
28
+
@@ -0,0 +1,3 @@
1
+ # Table Data Converter
2
+
3
+ This is a python-based tool that converts tables from one format to another. It can convert tables from CSV, TSV, Excel, JSON, and JSON Lines to any of these formats.
@@ -0,0 +1,34 @@
1
+ [tool.poetry]
2
+ name = "python-table-processor"
3
+ version = "0.2.29"
4
+ description = "A table data processor"
5
+ authors = ["Akiva Miura <akiva.miura@gmail.com>"]
6
+ license = "MIT"
7
+ readme = "README.md"
8
+ repository = "https://github.com/akivajp/python-table-processor"
9
+ packages = [
10
+ { include = "table_processor" },
11
+ ]
12
+
13
+ [tool.poetry-dynamic-versioning]
14
+ enable = false
15
+ style = "pep440"
16
+
17
+ [tool.poetry.scripts]
18
+ table-processor = "table_processor.cli:main"
19
+ convert-tables = "table_processor.cli:command_convert_tables"
20
+
21
+ [tool.poetry.dependencies]
22
+ python = "^3.10"
23
+ icecream = "^2.1.3"
24
+ logzero = "^1.7.0"
25
+ tqdm = "^4.67.0"
26
+ pandas = "^2.2.3"
27
+ openpyxl = "^3.1.5"
28
+ pyyaml = "^6.0.2"
29
+ xlsxwriter = "^3.2.0"
30
+
31
+
32
+ [build-system]
33
+ requires = ["poetry-core"]
34
+ build-backend = "poetry.core.masonry.api"
@@ -0,0 +1,2 @@
1
+ __version__ = "0.2.29"
2
+ __version_tuple__ = (0, 2, 29)
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ import argparse
5
+ import os
6
+ import sys
7
+
8
+ from icecream import ic
9
+
10
+ def parse_and_run(
11
+ parser: argparse.ArgumentParser,
12
+ ):
13
+ if os.environ.get('DEBUG', '').lower() in ['1', 'true', 'yes', 'on']:
14
+ pass
15
+ else:
16
+ ic.disable()
17
+ ic()
18
+ args = parser.parse_args()
19
+ if args.verbose:
20
+ ic.enable()
21
+ ic(args)
22
+ if args.handler:
23
+ args.handler(args)
24
+ else:
25
+ parser.print_help()
26
+ sys.exit(1)
27
+
28
+ def command_convert_tables(
29
+ parser: argparse.ArgumentParser|None = None,
30
+ ):
31
+ if parser is None:
32
+ command_parser = argparse.ArgumentParser(
33
+ description='Convert a table to a different format.'
34
+ )
35
+ else:
36
+ command_parser = parser
37
+ from table_converter.commands.convert_tables import setup_parser
38
+ setup_parser(command_parser)
39
+ if parser is None:
40
+ parse_and_run(command_parser)
41
+
42
+ def setup_common_args(
43
+ parser: argparse.ArgumentParser,
44
+ ):
45
+ parser.add_argument(
46
+ '--verbose', '-v',
47
+ action='store_true',
48
+ )
49
+
50
+ def main():
51
+ parser = argparse.ArgumentParser(description='Table Data Converter')
52
+ setup_common_args(parser)
53
+ parser.set_defaults(handler=None)
54
+ subparsers = parser.add_subparsers(dest='command')
55
+
56
+ parser_convert_tables = subparsers.add_parser(
57
+ 'convert',
58
+ help='Convert a table to a different format.'
59
+ )
60
+ setup_common_args(parser_convert_tables)
61
+ command_convert_tables(parser_convert_tables)
62
+
63
+ parse_and_run(parser)
64
+
65
+ if __name__ == '__main__':
66
+ main()
@@ -0,0 +1,80 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ import argparse
4
+
5
+ from icecream import ic
6
+
7
+ from .. core.convert import convert
8
+
9
+ def run(
10
+ args: argparse.Namespace,
11
+ ):
12
+ convert(
13
+ input_files = args.input_files,
14
+ output_file = args.output_file,
15
+ output_file_filtered_out = args.output_file_filtered_out,
16
+ config_path = args.config,
17
+ list_actions = args.do_actions,
18
+ list_pick_columns = args.pick_columns,
19
+ action_delimiter = args.action_delimiter,
20
+ output_debug = args.output_debug,
21
+ verbose = args.verbose,
22
+ ignore_file_rows = args.ignore_file_rows,
23
+ )
24
+
25
+ def setup_parser(
26
+ parser: argparse.ArgumentParser,
27
+ ):
28
+ parser.add_argument(
29
+ 'input_files',
30
+ metavar='INPUT_FILE',
31
+ nargs='+',
32
+ help='Path to the input file.'
33
+ )
34
+ parser.add_argument(
35
+ '--output-file', '--output', '-o',
36
+ metavar='OUTPUT_FILE',
37
+ required=False,
38
+ help='Path to the output file.'
39
+ )
40
+ parser.add_argument(
41
+ '--output-file-filtered-out', '--output-filtered-out', '-f',
42
+ metavar='OUTPUT_FILE_FILTERED_OUT',
43
+ required=False,
44
+ help='Path to the output file for filtered out rows.',
45
+ )
46
+ parser.add_argument(
47
+ '--config', '-c',
48
+ type=str,
49
+ help='Path to the configuration file.',
50
+ )
51
+ parser.add_argument(
52
+ '--pick-columns', '--pick',
53
+ type=str,
54
+ nargs='+',
55
+ help='Pick column map',
56
+ )
57
+ parser.add_argument(
58
+ '--action-delimiter', '--do-delimiter', '--do-delim',
59
+ type=str,
60
+ default=':',
61
+ help='Action delimiter',
62
+ )
63
+ parser.add_argument(
64
+ '--do-actions', '--actions', '--do',
65
+ nargs='+',
66
+ type=str,
67
+ help='Actions to do',
68
+ )
69
+ parser.add_argument(
70
+ '--ignore-file-rows', '--ignore-rows', '--ignore',
71
+ nargs='+',
72
+ type=str,
73
+ help='Ignore tuples of file name and row index',
74
+ )
75
+ parser.add_argument(
76
+ '--output-debug',
77
+ action='store_true',
78
+ help='Output debug information',
79
+ )
80
+ parser.set_defaults(handler=run)