excel-list-transform 0.7.6__tar.gz → 0.7.9__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.
Files changed (41) hide show
  1. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/LICENSE.txt +1 -1
  2. {excel_list_transform-0.7.6/excel_list_transform.egg-info → excel_list_transform-0.7.9}/PKG-INFO +15 -8
  3. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/README.md +3 -3
  4. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/README_pypi.md +10 -3
  5. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9/excel_list_transform.egg-info}/PKG-INFO +15 -8
  6. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/excel_list_transform.egg-info/SOURCES.txt +2 -1
  7. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/excel_list_transform.egg-info/requires.txt +3 -3
  8. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/pyproject.toml +2 -2
  9. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/setup.py +5 -5
  10. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/__main__.py +1 -1
  11. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/check_indata_common.py +1 -1
  12. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/commontypes.py +1 -1
  13. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/config.py +6 -1
  14. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/config_enums.py +1 -1
  15. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/config_excel_list_transform.py +15 -3
  16. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/config_factory.py +1 -1
  17. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/config_xls_list_refmt_name.py +1 -1
  18. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/config_xls_list_refmt_num.py +1 -1
  19. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/file_extension.py +1 -1
  20. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/file_must_exist.py +1 -1
  21. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/generate_cfg.py +42 -107
  22. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/generate_txt.py +1 -1
  23. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/handle_csv.py +1 -1
  24. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/handle_empty_column.py +1 -1
  25. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/handle_excel.py +54 -6
  26. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/num_named_conversion.py +1 -1
  27. excel_list_transform-0.7.9/src/excel_list_transform/py.typed +2 -0
  28. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/rewrite_value.py +3 -2
  29. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/str_to_enum.py +1 -1
  30. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/transform_cmd.py +39 -18
  31. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/transform_func.py +1 -1
  32. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/transform_func_common.py +1 -1
  33. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/transform_func_named.py +1 -1
  34. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/transform_func_num.py +1 -1
  35. excel_list_transform-0.7.9/src/excel_list_transform/version.py +61 -0
  36. excel_list_transform-0.7.6/src/excel_list_transform/py.typed +0 -2
  37. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/excel_list_transform.egg-info/dependency_links.txt +0 -0
  38. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/excel_list_transform.egg-info/top_level.txt +0 -0
  39. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/setup.cfg +0 -0
  40. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/__init__.py +0 -0
  41. {excel_list_transform-0.7.6 → excel_list_transform-0.7.9}/src/excel_list_transform/recode.py +0 -0
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Tom Björkholm
3
+ Copyright (c) 2024-2025 Tom Björkholm
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: excel-list-transform
3
- Version: 0.7.6
3
+ Version: 0.7.9
4
4
  Summary: Transform a list in excel or CSV
5
5
  Author: Tom Björkholm
6
6
  Author-email: Tom Björkholm <klausuler_linnet0q@icloud.com>
@@ -8,15 +8,15 @@ Project-URL: Source code, https://bitbucket.org/tom-bjorkholm/excel-list-transfo
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.13.2
11
+ Requires-Python: <3.11,>=3.10
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE.txt
14
14
  Requires-Dist: openpyxl>=3.1.5
15
- Requires-Dist: types-openpyxl>=3.1.5.20250306
15
+ Requires-Dist: types-openpyxl>=3.1.5.20250602
16
16
  Requires-Dist: pylightxl>=1.61
17
- Requires-Dist: XlsxWriter>=3.2.2
17
+ Requires-Dist: XlsxWriter>=3.2.3
18
18
  Requires-Dist: pip>=25.0.1
19
- Requires-Dist: setuptools>=77.0.3
19
+ Requires-Dist: setuptools>=80.9.0
20
20
  Requires-Dist: build>=1.2.2.post1
21
21
  Requires-Dist: wheel>=0.45.1
22
22
  Dynamic: author
@@ -48,19 +48,19 @@ How this is done is governed by a configuration file. The application can create
48
48
 
49
49
  ## Installing it
50
50
 
51
- If you want to use it, install it using pip. A precondition is that you have Python 3.12.6 or newer installed on you computer. (Python version 3.10.5 or newer for version 0.5.)
51
+ If you want to use it, install it using pip. A precondition is that you have Python installed on you computer. See version table below for information on needed Python version.
52
52
  Python can be downloaded from [https://www.python.org/downloads/](https://www.python.org/downloads/).
53
53
 
54
54
  ### Installing on mac and Linux
55
55
 
56
56
  ````sh
57
- pip3 install excel-list-transform
57
+ pip3 install --upgrade excel-list-transform
58
58
  ````
59
59
 
60
60
  ### Installing on Microsoft Windows
61
61
 
62
62
  ````sh
63
- pip install excel-list-transform
63
+ pip install --upgrade excel-list-transform
64
64
  ````
65
65
 
66
66
  ## Version history
@@ -75,6 +75,11 @@ pip install excel-list-transform
75
75
  | 0.7.3 | 06 Jan 2025 | 3.12.6 or newer | Example config for Sailwave to RRS |
76
76
  | 0.7.5 | 21 Mar 2025 | 3.12.6 or newer | Example config for Sailarena to RRS |
77
77
  | 0.7.6 | 21 Mar 2025 | 3.13.2 or newer | Adapted to Python 3.13.2 |
78
+ | 0.7.7 | 09 Apr 2025 | 3.13.3 or newer | refactor phone number rewrite cfg |
79
+ | 0.7.9 | 09 Jun 2025 | 3.10.x | Backport 0.7.12 to Python 3.10 |
80
+ | 0.7.10 | 09 Jun 2025 | 3.11.x | Backport 0.7.12 to Python 3.11 |
81
+ | 0.7.11 | 09 Jun 2025 | 3.12.x | Backport 0.7.12 to Python 3.12 |
82
+ | 0.7.12 | 09 Jun 2025 | 3.13 or newer | Add version sub-command |
78
83
 
79
84
  ## Running the application
80
85
 
@@ -82,6 +87,7 @@ pip install excel-list-transform
82
87
 
83
88
  ````sh
84
89
  python3 -m excel_list_transform --help
90
+ python3 -m excel_list_transform version
85
91
  python3 -m excel_list_transform cfg-example --help
86
92
  python3 -m excel_list_transform transform --help
87
93
  python3 -m excel_list_transform cfg-example -k forms_to_rrs -r by_name -o example.cfg
@@ -92,6 +98,7 @@ python3 -m excel_list_transform transform -c example.cfg -i input.xlsx -o output
92
98
 
93
99
  ````sh
94
100
  python -m excel_list_transform --help
101
+ python -m excel_list_transform version
95
102
  python -m excel_list_transform cfg-example --help
96
103
  python -m excel_list_transform transform --help
97
104
  python -m excel_list_transform cfg-example -k forms_to_rrs -r by_name -o example.cfg
@@ -11,13 +11,13 @@ If you want to use it install it using pip from [https://pypi.org/project/excel-
11
11
  ### Installing on mac and Linux
12
12
 
13
13
  ````
14
- pip3 install excel-list-transform
14
+ pip3 install --upgrade excel-list-transform
15
15
  ````
16
16
 
17
17
  ### Installing on Microsoft Windows
18
18
 
19
19
  ````
20
- pip install excel-list-transform
20
+ pip install --upgrade excel-list-transform
21
21
  ````
22
22
 
23
23
  ### Information for use
@@ -50,7 +50,7 @@ For running the script and running the test suite you need a mac or a Linux comp
50
50
 
51
51
  #### Python version
52
52
 
53
- The tests and the script for running the tests, coverage, mypy etc. requires Python version 3.12.6 or newer.
53
+ Please see README_pypi.md for information on needed python version. Main development is on newest Python version, and may be backported to older Python version on a branch.
54
54
 
55
55
  #### Zsh
56
56
 
@@ -22,19 +22,19 @@ How this is done is governed by a configuration file. The application can create
22
22
 
23
23
  ## Installing it
24
24
 
25
- If you want to use it, install it using pip. A precondition is that you have Python 3.12.6 or newer installed on you computer. (Python version 3.10.5 or newer for version 0.5.)
25
+ If you want to use it, install it using pip. A precondition is that you have Python installed on you computer. See version table below for information on needed Python version.
26
26
  Python can be downloaded from [https://www.python.org/downloads/](https://www.python.org/downloads/).
27
27
 
28
28
  ### Installing on mac and Linux
29
29
 
30
30
  ````sh
31
- pip3 install excel-list-transform
31
+ pip3 install --upgrade excel-list-transform
32
32
  ````
33
33
 
34
34
  ### Installing on Microsoft Windows
35
35
 
36
36
  ````sh
37
- pip install excel-list-transform
37
+ pip install --upgrade excel-list-transform
38
38
  ````
39
39
 
40
40
  ## Version history
@@ -49,6 +49,11 @@ pip install excel-list-transform
49
49
  | 0.7.3 | 06 Jan 2025 | 3.12.6 or newer | Example config for Sailwave to RRS |
50
50
  | 0.7.5 | 21 Mar 2025 | 3.12.6 or newer | Example config for Sailarena to RRS |
51
51
  | 0.7.6 | 21 Mar 2025 | 3.13.2 or newer | Adapted to Python 3.13.2 |
52
+ | 0.7.7 | 09 Apr 2025 | 3.13.3 or newer | refactor phone number rewrite cfg |
53
+ | 0.7.9 | 09 Jun 2025 | 3.10.x | Backport 0.7.12 to Python 3.10 |
54
+ | 0.7.10 | 09 Jun 2025 | 3.11.x | Backport 0.7.12 to Python 3.11 |
55
+ | 0.7.11 | 09 Jun 2025 | 3.12.x | Backport 0.7.12 to Python 3.12 |
56
+ | 0.7.12 | 09 Jun 2025 | 3.13 or newer | Add version sub-command |
52
57
 
53
58
  ## Running the application
54
59
 
@@ -56,6 +61,7 @@ pip install excel-list-transform
56
61
 
57
62
  ````sh
58
63
  python3 -m excel_list_transform --help
64
+ python3 -m excel_list_transform version
59
65
  python3 -m excel_list_transform cfg-example --help
60
66
  python3 -m excel_list_transform transform --help
61
67
  python3 -m excel_list_transform cfg-example -k forms_to_rrs -r by_name -o example.cfg
@@ -66,6 +72,7 @@ python3 -m excel_list_transform transform -c example.cfg -i input.xlsx -o output
66
72
 
67
73
  ````sh
68
74
  python -m excel_list_transform --help
75
+ python -m excel_list_transform version
69
76
  python -m excel_list_transform cfg-example --help
70
77
  python -m excel_list_transform transform --help
71
78
  python -m excel_list_transform cfg-example -k forms_to_rrs -r by_name -o example.cfg
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: excel-list-transform
3
- Version: 0.7.6
3
+ Version: 0.7.9
4
4
  Summary: Transform a list in excel or CSV
5
5
  Author: Tom Björkholm
6
6
  Author-email: Tom Björkholm <klausuler_linnet0q@icloud.com>
@@ -8,15 +8,15 @@ Project-URL: Source code, https://bitbucket.org/tom-bjorkholm/excel-list-transfo
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.13.2
11
+ Requires-Python: <3.11,>=3.10
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE.txt
14
14
  Requires-Dist: openpyxl>=3.1.5
15
- Requires-Dist: types-openpyxl>=3.1.5.20250306
15
+ Requires-Dist: types-openpyxl>=3.1.5.20250602
16
16
  Requires-Dist: pylightxl>=1.61
17
- Requires-Dist: XlsxWriter>=3.2.2
17
+ Requires-Dist: XlsxWriter>=3.2.3
18
18
  Requires-Dist: pip>=25.0.1
19
- Requires-Dist: setuptools>=77.0.3
19
+ Requires-Dist: setuptools>=80.9.0
20
20
  Requires-Dist: build>=1.2.2.post1
21
21
  Requires-Dist: wheel>=0.45.1
22
22
  Dynamic: author
@@ -48,19 +48,19 @@ How this is done is governed by a configuration file. The application can create
48
48
 
49
49
  ## Installing it
50
50
 
51
- If you want to use it, install it using pip. A precondition is that you have Python 3.12.6 or newer installed on you computer. (Python version 3.10.5 or newer for version 0.5.)
51
+ If you want to use it, install it using pip. A precondition is that you have Python installed on you computer. See version table below for information on needed Python version.
52
52
  Python can be downloaded from [https://www.python.org/downloads/](https://www.python.org/downloads/).
53
53
 
54
54
  ### Installing on mac and Linux
55
55
 
56
56
  ````sh
57
- pip3 install excel-list-transform
57
+ pip3 install --upgrade excel-list-transform
58
58
  ````
59
59
 
60
60
  ### Installing on Microsoft Windows
61
61
 
62
62
  ````sh
63
- pip install excel-list-transform
63
+ pip install --upgrade excel-list-transform
64
64
  ````
65
65
 
66
66
  ## Version history
@@ -75,6 +75,11 @@ pip install excel-list-transform
75
75
  | 0.7.3 | 06 Jan 2025 | 3.12.6 or newer | Example config for Sailwave to RRS |
76
76
  | 0.7.5 | 21 Mar 2025 | 3.12.6 or newer | Example config for Sailarena to RRS |
77
77
  | 0.7.6 | 21 Mar 2025 | 3.13.2 or newer | Adapted to Python 3.13.2 |
78
+ | 0.7.7 | 09 Apr 2025 | 3.13.3 or newer | refactor phone number rewrite cfg |
79
+ | 0.7.9 | 09 Jun 2025 | 3.10.x | Backport 0.7.12 to Python 3.10 |
80
+ | 0.7.10 | 09 Jun 2025 | 3.11.x | Backport 0.7.12 to Python 3.11 |
81
+ | 0.7.11 | 09 Jun 2025 | 3.12.x | Backport 0.7.12 to Python 3.12 |
82
+ | 0.7.12 | 09 Jun 2025 | 3.13 or newer | Add version sub-command |
78
83
 
79
84
  ## Running the application
80
85
 
@@ -82,6 +87,7 @@ pip install excel-list-transform
82
87
 
83
88
  ````sh
84
89
  python3 -m excel_list_transform --help
90
+ python3 -m excel_list_transform version
85
91
  python3 -m excel_list_transform cfg-example --help
86
92
  python3 -m excel_list_transform transform --help
87
93
  python3 -m excel_list_transform cfg-example -k forms_to_rrs -r by_name -o example.cfg
@@ -92,6 +98,7 @@ python3 -m excel_list_transform transform -c example.cfg -i input.xlsx -o output
92
98
 
93
99
  ````sh
94
100
  python -m excel_list_transform --help
101
+ python -m excel_list_transform version
95
102
  python -m excel_list_transform cfg-example --help
96
103
  python -m excel_list_transform transform --help
97
104
  python -m excel_list_transform cfg-example -k forms_to_rrs -r by_name -o example.cfg
@@ -34,4 +34,5 @@ src/excel_list_transform/transform_cmd.py
34
34
  src/excel_list_transform/transform_func.py
35
35
  src/excel_list_transform/transform_func_common.py
36
36
  src/excel_list_transform/transform_func_named.py
37
- src/excel_list_transform/transform_func_num.py
37
+ src/excel_list_transform/transform_func_num.py
38
+ src/excel_list_transform/version.py
@@ -1,8 +1,8 @@
1
1
  openpyxl>=3.1.5
2
- types-openpyxl>=3.1.5.20250306
2
+ types-openpyxl>=3.1.5.20250602
3
3
  pylightxl>=1.61
4
- XlsxWriter>=3.2.2
4
+ XlsxWriter>=3.2.3
5
5
  pip>=25.0.1
6
- setuptools>=77.0.3
6
+ setuptools>=80.9.0
7
7
  build>=1.2.2.post1
8
8
  wheel>=0.45.1
@@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "excel-list-transform"
7
- version = "0.7.6"
7
+ version = "0.7.9"
8
8
  authors = [
9
9
  { name="Tom Björkholm", email="klausuler_linnet0q@icloud.com" },
10
10
  ]
11
11
  description = "Transform a list in excel or CSV"
12
12
  readme = "README_pypi.md"
13
- requires-python = ">=3.13.2"
13
+ requires-python = "<3.11,>=3.10"
14
14
  classifiers = [
15
15
  "Programming Language :: Python :: 3",
16
16
  "License :: OSI Approved :: MIT License",
@@ -5,21 +5,21 @@ from setuptools import setup
5
5
 
6
6
  setup(
7
7
  name='excel-list-transform',
8
- version='0.7.6',
8
+ version='0.7.9',
9
9
  description='Transform a list in excel or CSV.',
10
10
  author='Tom Björkholm',
11
11
  author_email='klausuler_linnet0q@icloud.com',
12
- python_requires='>=3.13.2',
12
+ python_requires='<3.11,>=3.10',
13
13
  packages=['excel_list_transform'],
14
14
  package_dir={'excel_list_transform': 'src/excel_list_transform'},
15
15
  package_data={'excel_list_transform': ['src/py.typed']},
16
16
  install_requires=[
17
17
  'openpyxl >= 3.1.5',
18
- 'types-openpyxl >= 3.1.5.20250306',
18
+ 'types-openpyxl >= 3.1.5.20250602',
19
19
  'pylightxl >= 1.61',
20
- 'XlsxWriter >= 3.2.2',
20
+ 'XlsxWriter >= 3.2.3',
21
21
  'pip >= 25.0.1',
22
- 'setuptools >= 77.0.3',
22
+ 'setuptools >= 80.9.0',
23
23
  'build >= 1.2.2.post1',
24
24
  'wheel>=0.45.1'
25
25
  ]
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Take an excel file and and change columns before saving as excel or CSV."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Function for common indata checks.."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Common type definitions used for type hints."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Base class to read and write configurations."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -387,6 +387,11 @@ class Config():
387
387
  if 'unknown encoding' in str(exc):
388
388
  return False
389
389
  raise exc # pragma: no cover
390
+ except OSError as exc:
391
+ # workaround for Python 3.10 bug
392
+ if 'Bad file descriptor' in str(exc):
393
+ return False
394
+ raise exc # pragma: no cover
390
395
  return True
391
396
 
392
397
  @staticmethod
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Enumerations used in configuration of excel list transform."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,14 +1,14 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Read and write configuration of excel list transform."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
8
8
  import sys
9
9
  from copy import deepcopy
10
10
  from enum import Enum
11
- from typing import Optional, Callable, TypeAlias, TypeVar, NamedTuple, Generic
11
+ from typing import Optional, Callable, TypeAlias, TypeVar, Generic
12
12
  from csv import Dialect
13
13
  from excel_list_transform.config import Config, ParseConverter
14
14
  from excel_list_transform.config_enums import FileType, SplitWhere, \
@@ -45,7 +45,7 @@ NoDupKeydType: TypeAlias = \
45
45
  Rule[Column] | RuleMerge[Column] | RuleSplit[Column]
46
46
 
47
47
 
48
- class ColInfo(NamedTuple, Generic[Column]):
48
+ class ColInfo(Generic[Column]): # pylint: disable=too-few-public-methods
49
49
  """Information about columns to pass to ConfigExcelListTransform init."""
50
50
 
51
51
  split_last: str
@@ -55,6 +55,18 @@ class ColInfo(NamedTuple, Generic[Column]):
55
55
  col_to_use: list[Column]
56
56
  tinfo: Column
57
57
 
58
+ def __init__(self, # pylint: disable=too-many-arguments, too-many-positional-arguments # noqa: E501
59
+ split_last: str, insert_last: Optional[str],
60
+ s1: RuleSplit[Column], s6: Rule[Column],
61
+ col_to_use: list[Column], tinfo: Column):
62
+ """Create a ColInfo object."""
63
+ self.split_last = split_last
64
+ self.insert_last = insert_last
65
+ self.s1 = s1
66
+ self.s6 = s6
67
+ self.col_to_use = col_to_use
68
+ self.tinfo = tinfo
69
+
58
70
 
59
71
  class ConfigExcelListTransform(Config, Generic[Column]): # pylint: disable=too-many-instance-attributes, line-too-long # noqa: E501
60
72
  """Class with configuration for excel list transform."""
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Get correct configuration type."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Read and write configuration of CSV splitting."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Read and write configuration of CSV splitting."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Functions to add and remove file extensions."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Function for checking that file exists."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,15 +1,17 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Generate example configuration files."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
-
7
+ from copy import deepcopy
8
8
  from excel_list_transform.file_extension import fix_file_extension
9
9
  from excel_list_transform.config_enums import ColumnRef, FileType, \
10
10
  RewriteKind, CaseSensitivity, ExcelLib, SplitWhere
11
11
  from excel_list_transform.config_factory import config_factory_from_enum
12
12
  from excel_list_transform.generate_txt import generate_syntax_txt
13
+ from excel_list_transform.config_excel_list_transform import \
14
+ Column, SingleRuleRewrite, RuleRewrite
13
15
  from excel_list_transform.config_xls_list_refmt_name import \
14
16
  ConfigXlsListRefmtName
15
17
  from excel_list_transform.config_xls_list_refmt_num import \
@@ -88,6 +90,36 @@ format of the phone number and save to excel.
88
90
  ''' + syntax_phone_fix
89
91
 
90
92
 
93
+ def rewrite_phone_46_cfg(cfg: ConfigXlsListRefmtName | ConfigXlsListRefmtNum,
94
+ column: Column, append: bool) -> None:
95
+ """Add configuration to rewrite +46 phone numbers."""
96
+ assert (isinstance(cfg, ConfigXlsListRefmtName) and
97
+ isinstance(column, str)) or \
98
+ (isinstance(cfg, ConfigXlsListRefmtNum) and
99
+ isinstance(column, int))
100
+ assert isinstance(append, bool)
101
+ rules: RuleRewrite[Column] = [
102
+ {'kind': RewriteKind.STRIP,
103
+ 'chars': '', 'case': CaseSensitivity.IGNORE_CASE},
104
+ {'kind': RewriteKind.REMOVECHARS,
105
+ 'chars': [' ', '-', '(', ')'], 'case': CaseSensitivity.MATCH_CASE},
106
+ {'kind': RewriteKind.REGEX_SUBSTITUTE,
107
+ 'from': '^07', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
108
+ {'kind': RewriteKind.REGEX_SUBSTITUTE,
109
+ 'from': '^\\+4607', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
110
+ {'kind': RewriteKind.REGEX_SUBSTITUTE,
111
+ 'from': '^467', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
112
+ {'kind': RewriteKind.REGEX_SUBSTITUTE,
113
+ 'from': '^4607', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE}
114
+ ]
115
+ if not append:
116
+ cfg.s7_rewrite_columns.clear()
117
+ for rule in rules:
118
+ newrule: SingleRuleRewrite[Column] = deepcopy(rule)
119
+ newrule['column'] = column
120
+ cfg.s7_rewrite_columns.append(newrule)
121
+
122
+
91
123
  def generate_syntax_sa2r_name(filename: str, colref: ColumnRef) -> None:
92
124
  """Generate config example for sa_to_rrs."""
93
125
  assert colref == ColumnRef.BY_NAME
@@ -105,19 +137,7 @@ def generate_syntax_sa2r_name(filename: str, colref: ColumnRef) -> None:
105
137
  cfg.s3_merge_columns = []
106
138
  cfg.s5_rename_columns = []
107
139
  cfg.s6_insert_columns = []
108
- cfg.s7_rewrite_columns = [
109
- {'column': 'Phone', 'kind': RewriteKind.STRIP,
110
- 'chars': '', 'case': CaseSensitivity.IGNORE_CASE},
111
- {'column': 'Phone', 'kind': RewriteKind.REMOVECHARS,
112
- 'chars': [' ', '-'], 'case': CaseSensitivity.MATCH_CASE},
113
- {'column': 'Phone', 'kind': RewriteKind.REGEX_SUBSTITUTE,
114
- 'from': '^07', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
115
- {'column': 'Phone', 'kind': RewriteKind.REGEX_SUBSTITUTE,
116
- 'from': '^\\+4607', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
117
- {'column': 'Phone', 'kind': RewriteKind.REGEX_SUBSTITUTE,
118
- 'from': '^467', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
119
- {'column': 'Phone', 'kind': RewriteKind.REGEX_SUBSTITUTE,
120
- 'from': '^4607', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE}]
140
+ rewrite_phone_46_cfg(cfg=cfg, column='Phone', append=False)
121
141
  cfg.s8_column_order = ['Class', 'Division', 'Nationality',
122
142
  'Sail Number', 'Boat Name', 'First Name',
123
143
  'Last Name', 'Club Name', 'Email', 'Phone',
@@ -139,19 +159,7 @@ def generate_syntax_sw2r_name(filename: str, colref: ColumnRef) -> None:
139
159
  cfg.s3_merge_columns = []
140
160
  cfg.s5_rename_columns = [{'column': 'Name', 'name': 'First Name'}]
141
161
  cfg.s6_insert_columns = [{'column': 'WhatsApp', 'value': None}]
142
- cfg.s7_rewrite_columns = [
143
- {'column': 'Phone', 'kind': RewriteKind.STRIP,
144
- 'chars': '', 'case': CaseSensitivity.IGNORE_CASE},
145
- {'column': 'Phone', 'kind': RewriteKind.REMOVECHARS,
146
- 'chars': [' ', '-'], 'case': CaseSensitivity.MATCH_CASE},
147
- {'column': 'Phone', 'kind': RewriteKind.REGEX_SUBSTITUTE,
148
- 'from': '^07', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
149
- {'column': 'Phone', 'kind': RewriteKind.REGEX_SUBSTITUTE,
150
- 'from': '^\\+4607', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
151
- {'column': 'Phone', 'kind': RewriteKind.REGEX_SUBSTITUTE,
152
- 'from': '^467', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
153
- {'column': 'Phone', 'kind': RewriteKind.REGEX_SUBSTITUTE,
154
- 'from': '^4607', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE}]
162
+ rewrite_phone_46_cfg(cfg=cfg, column='Phone', append=False)
155
163
  cfg.s8_column_order = ['Class', 'Division', 'Nationality',
156
164
  'Sail Number', 'Boat Name', 'First Name',
157
165
  'Last Name', 'Club Name', 'Email', 'Phone',
@@ -182,19 +190,7 @@ def generate_syntax_sa2r_num(filename: str, colref: ColumnRef) -> None:
182
190
  cfg.s4_place_columns_first = []
183
191
  cfg.s5_rename_columns = []
184
192
  cfg.s6_insert_columns = []
185
- cfg.s7_rewrite_columns = [
186
- {'column': 9, 'kind': RewriteKind.STRIP,
187
- 'chars': '', 'case': CaseSensitivity.IGNORE_CASE},
188
- {'column': 9, 'kind': RewriteKind.REMOVECHARS,
189
- 'chars': [' ', '-'], 'case': CaseSensitivity.MATCH_CASE},
190
- {'column': 9, 'kind': RewriteKind.REGEX_SUBSTITUTE,
191
- 'from': '^07', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
192
- {'column': 9, 'kind': RewriteKind.REGEX_SUBSTITUTE,
193
- 'from': '^\\+4607', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
194
- {'column': 9, 'kind': RewriteKind.REGEX_SUBSTITUTE,
195
- 'from': '^467', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
196
- {'column': 9, 'kind': RewriteKind.REGEX_SUBSTITUTE,
197
- 'from': '^4607', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE}]
193
+ rewrite_phone_46_cfg(cfg=cfg, column=9, append=False)
198
194
  cfg.write(to_json_filename=filename)
199
195
 
200
196
 
@@ -216,19 +212,7 @@ def generate_syntax_sw2r_num(filename: str, colref: ColumnRef) -> None:
216
212
  {'column': 6, 'name': 'Last Name'}]
217
213
  cfg.s6_insert_columns = [{'column': 10, 'name': 'WhatsApp',
218
214
  'value': None}]
219
- cfg.s7_rewrite_columns = [
220
- {'column': 9, 'kind': RewriteKind.STRIP,
221
- 'chars': '', 'case': CaseSensitivity.IGNORE_CASE},
222
- {'column': 9, 'kind': RewriteKind.REMOVECHARS,
223
- 'chars': [' ', '-'], 'case': CaseSensitivity.MATCH_CASE},
224
- {'column': 9, 'kind': RewriteKind.REGEX_SUBSTITUTE,
225
- 'from': '^07', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
226
- {'column': 9, 'kind': RewriteKind.REGEX_SUBSTITUTE,
227
- 'from': '^\\+4607', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
228
- {'column': 9, 'kind': RewriteKind.REGEX_SUBSTITUTE,
229
- 'from': '^467', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
230
- {'column': 9, 'kind': RewriteKind.REGEX_SUBSTITUTE,
231
- 'from': '^4607', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE}]
215
+ rewrite_phone_46_cfg(cfg=cfg, column=9, append=False)
232
216
  cfg.write(to_json_filename=filename)
233
217
 
234
218
 
@@ -258,19 +242,7 @@ def generate_syntax_o2r_name(filename: str, colref: ColumnRef) -> None:
258
242
  {'column': 'Division', 'value': None},
259
243
  {'column': 'Boat Name', 'value': None},
260
244
  {'column': 'WhatsApp', 'value': None}]
261
- cfg.s7_rewrite_columns = [
262
- {'column': 'Phone', 'kind': RewriteKind.STRIP,
263
- 'chars': '', 'case': CaseSensitivity.IGNORE_CASE},
264
- {'column': 'Phone', 'kind': RewriteKind.REMOVECHARS,
265
- 'chars': [' ', '-'], 'case': CaseSensitivity.MATCH_CASE},
266
- {'column': 'Phone', 'kind': RewriteKind.REGEX_SUBSTITUTE,
267
- 'from': '^07', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
268
- {'column': 'Phone', 'kind': RewriteKind.REGEX_SUBSTITUTE,
269
- 'from': '^\\+4607', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
270
- {'column': 'Phone', 'kind': RewriteKind.REGEX_SUBSTITUTE,
271
- 'from': '^467', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
272
- {'column': 'Phone', 'kind': RewriteKind.REGEX_SUBSTITUTE,
273
- 'from': '^4607', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE}]
245
+ rewrite_phone_46_cfg(cfg=cfg, column='Phone', append=False)
274
246
  cfg.s8_column_order = ['Class', 'Division', 'Nationality',
275
247
  'Sail Number', 'Boat Name', 'First Name',
276
248
  'Last Name', 'Club Name', 'Email', 'Phone',
@@ -305,19 +277,7 @@ def generate_syntax_o2r_num(filename: str, colref: ColumnRef) -> None:
305
277
  {'column': 1, 'name': 'Division', 'value': None},
306
278
  {'column': 4, 'name': 'Boat Name', 'value': None},
307
279
  {'column': 10, 'name': 'WhatsApp', 'value': None}]
308
- cfg.s7_rewrite_columns = [
309
- {'column': 9, 'kind': RewriteKind.STRIP,
310
- 'chars': '', 'case': CaseSensitivity.IGNORE_CASE},
311
- {'column': 9, 'kind': RewriteKind.REMOVECHARS,
312
- 'chars': [' ', '-'], 'case': CaseSensitivity.MATCH_CASE},
313
- {'column': 9, 'kind': RewriteKind.REGEX_SUBSTITUTE,
314
- 'from': '^07', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
315
- {'column': 9, 'kind': RewriteKind.REGEX_SUBSTITUTE,
316
- 'from': '^\\+4607', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
317
- {'column': 9, 'kind': RewriteKind.REGEX_SUBSTITUTE,
318
- 'from': '^467', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
319
- {'column': 9, 'kind': RewriteKind.REGEX_SUBSTITUTE,
320
- 'from': '^4607', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE}]
280
+ rewrite_phone_46_cfg(cfg=cfg, column=9, append=False)
321
281
  cfg.write(to_json_filename=filename)
322
282
 
323
283
 
@@ -353,20 +313,7 @@ def generate_syntax_o2s_name(filename: str, colref: ColumnRef) -> None:
353
313
  cfg.s6_insert_columns = [
354
314
  {'column': 'Division', 'value': None},
355
315
  {'column': 'Boat', 'value': None}]
356
- cfg.s7_rewrite_columns = [
357
- {'column': 'HelmPhone', 'kind': RewriteKind.STRIP,
358
- 'chars': '', 'case': CaseSensitivity.IGNORE_CASE},
359
- {'column': 'HelmPhone', 'kind': RewriteKind.REMOVECHARS,
360
- 'chars': [' ', '-'], 'case': CaseSensitivity.MATCH_CASE},
361
- {'column': 'HelmPhone', 'kind': RewriteKind.REGEX_SUBSTITUTE,
362
- 'from': '^07', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
363
- {'column': 'HelmPhone', 'kind': RewriteKind.REGEX_SUBSTITUTE,
364
- 'from': '^\\+4607', 'to': '+467',
365
- 'case': CaseSensitivity.MATCH_CASE},
366
- {'column': 'HelmPhone', 'kind': RewriteKind.REGEX_SUBSTITUTE,
367
- 'from': '^467', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
368
- {'column': 'HelmPhone', 'kind': RewriteKind.REGEX_SUBSTITUTE,
369
- 'from': '^4607', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE}]
316
+ rewrite_phone_46_cfg(cfg=cfg, column='HelmPhone', append=False)
370
317
  cfg.s8_column_order = ['Class', 'Division', 'Nat', 'SailNo', 'Boat',
371
318
  'HelmName', 'Club', 'HelmEmail', 'HelmPhone']
372
319
  cfg.write(to_json_filename=filename)
@@ -397,19 +344,7 @@ def generate_syntax_o2s_num(filename: str, colref: ColumnRef) -> None:
397
344
  cfg.s6_insert_columns = [
398
345
  {'column': 1, 'name': 'Division', 'value': None},
399
346
  {'column': 4, 'name': 'Boat', 'value': None}]
400
- cfg.s7_rewrite_columns = [
401
- {'column': 8, 'kind': RewriteKind.STRIP,
402
- 'chars': '', 'case': CaseSensitivity.IGNORE_CASE},
403
- {'column': 8, 'kind': RewriteKind.REMOVECHARS,
404
- 'chars': [' ', '-'], 'case': CaseSensitivity.MATCH_CASE},
405
- {'column': 8, 'kind': RewriteKind.REGEX_SUBSTITUTE,
406
- 'from': '^07', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
407
- {'column': 8, 'kind': RewriteKind.REGEX_SUBSTITUTE,
408
- 'from': '^\\+4607', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
409
- {'column': 8, 'kind': RewriteKind.REGEX_SUBSTITUTE,
410
- 'from': '^467', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
411
- {'column': 8, 'kind': RewriteKind.REGEX_SUBSTITUTE,
412
- 'from': '^4607', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE}]
347
+ rewrite_phone_46_cfg(cfg=cfg, column=8, append=False)
413
348
  cfg.write(to_json_filename=filename)
414
349
 
415
350
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Generate example configuration files."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Handle reading and writing of an excel file."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Handle empty column in input."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,28 +1,76 @@
1
1
  #! /usr/bin/python3
2
2
  """Handle reading and writing of an excel file."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
8
8
  # https://realpython.com/openpyxl-excel-spreadsheets-python/
9
9
 
10
10
  import sys
11
+ from datetime import datetime, date, time
11
12
  from copy import deepcopy
12
- from typing import Optional
13
- from openpyxl import load_workbook as openpyxl_load_workbook
14
- from openpyxl import Workbook as openpyxl_wb
13
+ from typing import Optional, TypeAlias, Any
14
+ from decimal import Decimal
15
15
  from xlsxwriter import Workbook as xlsxwriter_wb # type: ignore
16
16
  from pylightxl import readxl as pl_readxl # type: ignore
17
17
  from pylightxl import Database as pl_db, writexl as pl_writexl
18
+ from openpyxl import load_workbook as openpyxl_load_workbook
19
+ from openpyxl import Workbook as openpyxl_wb
20
+ try:
21
+ # only availabe in mypy, flake8 and pylint, not in python
22
+ from openpyxl.cell import _CellGetValue # pylint: disable=unused-import # noqa: F401,E501
23
+ except ImportError:
24
+ pass
18
25
  from excel_list_transform.commontypes import NameData, NameDataMap, \
19
- NumData, NumDataSeq
26
+ NumData, NumDataSeq, NumRow
20
27
  from excel_list_transform.config_enums import ExcelLib
21
28
  from excel_list_transform.handle_empty_column import handle_empty_column_in_lst
22
29
  from excel_list_transform.num_named_conversion import \
23
30
  named_cols_from_num_cols, num_cols_from_named_cols
24
31
 
25
32
 
33
+ _AnyCellValue: TypeAlias = Any # AnyOf _CellGetValue # noqa: Y047
34
+ seentypes: list[str] = []
35
+
36
+
37
+ def fix_row_openpyxl(row: tuple[_AnyCellValue, ...],
38
+ max_column_reed: int) -> NumRow:
39
+ """Convert types in row from openpyxl to those supported."""
40
+ ret: NumRow = []
41
+ colnum = 0
42
+ for cell in row:
43
+ if colnum >= max_column_reed:
44
+ continue
45
+ colnum += 1
46
+ if cell is None:
47
+ ret.append(None)
48
+ elif isinstance(cell, (str, int, float, datetime)):
49
+ assert isinstance(cell, (str, int, float, datetime))
50
+ ret.append(cell)
51
+ elif isinstance(cell, date):
52
+ assert isinstance(cell, date)
53
+ ret.append(datetime(year=cell.year,
54
+ month=cell.month,
55
+ day=cell.day))
56
+ elif isinstance(cell, Decimal):
57
+ assert isinstance(cell, Decimal)
58
+ ret.append(float(cell))
59
+ elif isinstance(cell, time):
60
+ assert isinstance(cell, time)
61
+ ret.append(cell.isoformat())
62
+ else:
63
+ typename = type(cell).__name__
64
+ if typename not in seentypes:
65
+ print('Sorry, cells with value of type ' +
66
+ f'{typename} are not supported\n' +
67
+ 'Trying to convert to string.',
68
+ file=sys.stderr)
69
+ seentypes.append(typename)
70
+ ret.append(str(cell))
71
+ return ret
72
+
73
+
26
74
  def read_excel_openpyxl(filename: str,
27
75
  max_column_read: int) \
28
76
  -> NumData:
@@ -33,7 +81,7 @@ def read_excel_openpyxl(filename: str,
33
81
  assert sheet is not None
34
82
  res: NumData = []
35
83
  for row in sheet.iter_rows(values_only=True):
36
- res.append(list(row)[:max_column_read])
84
+ res.append(fix_row_openpyxl(row, max_column_reed=max_column_read))
37
85
  return handle_empty_column_in_lst(res)
38
86
 
39
87
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Convert data between numbered columns and named columns."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -0,0 +1,2 @@
1
+ # Copyright (c) 2024-2025 Tom Björkholm
2
+ # MIT License
@@ -1,17 +1,18 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Functions for manipulating and rewriting a value."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
8
8
  from copy import deepcopy
9
9
  import sys
10
- from typing import Optional, assert_never
10
+ from typing import Optional
11
11
  from re import compile as re_compile
12
12
  from re import Pattern
13
13
  from re import IGNORECASE as re_IGNORECASE
14
14
  from re import error as re_error
15
+ from typing_extensions import assert_never
15
16
  from excel_list_transform.commontypes import get_checked_type
16
17
  from excel_list_transform.config_enums import RewriteKind, CaseSensitivity
17
18
  from excel_list_transform.config_excel_list_transform import \
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Functions to fuzzy parse string into enum."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Command to transform list in excel or CSV file."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -14,6 +14,7 @@ from excel_list_transform.generate_cfg import generate_examplecfg
14
14
  from excel_list_transform.generate_cfg import get_example_names
15
15
  from excel_list_transform.config_enums import ColumnRef
16
16
  from excel_list_transform.str_to_enum import string_to_enum_best_match
17
+ from excel_list_transform.version import Version
17
18
 
18
19
 
19
20
  def gen_cfg_cmd(args: argparse.Namespace) -> int:
@@ -36,6 +37,13 @@ def rfmt_cmd(args: argparse.Namespace) -> int:
36
37
  cfgfilename=cfgfilename)
37
38
 
38
39
 
40
+ def version_cmd(_: argparse.Namespace) -> int:
41
+ """Print version information."""
42
+ vers = Version()
43
+ vers.print()
44
+ return 0
45
+
46
+
39
47
  USAGE_ORDER = '''
40
48
  The normal way to use this command is:
41
49
  (1) Using the "example" sub-command a few example configuration (.cfg) files
@@ -109,23 +117,35 @@ def gen_cfg_args(subparsers: SubParseAct) -> None:
109
117
  gen_cfg_args_named(subparsers=subparsers, sub_pars_name='cfg-example')
110
118
 
111
119
 
112
- def rfmt_args(subparsers: SubParseAct) -> None:
120
+ def transf_args(subparsers: SubParseAct) -> None:
113
121
  """Add arguments for transform sub-command."""
114
- rfmt_help = 'Transform list in excel or CSV file. How data is transformed '
115
- rfmt_help += 'is described in a configuration file. Name of input file, '
116
- rfmt_help += 'output file and configuration file is given as command '
117
- rfmt_help += 'line arguments.'
118
- rfmt_parser = subparsers.add_parser('transform', help=rfmt_help,
119
- epilog=USAGE_ORDER,
120
- description=rfmt_help + SEE_MAIN_HELP)
121
- rfmt_parser.set_defaults(func=rfmt_cmd)
122
- rfmt_parser.add_argument('-c', '--cfg', nargs=1, required=True,
123
- help='Configuation file name to use.')
124
- rfmt_parser.add_argument('-i', '--input', nargs=1,
125
- help='Name of input file.', required=True)
126
- rfmt_parser.add_argument('-o', '--output', nargs=1,
127
- help='Name of output file to create.',
128
- required=True)
122
+ transf_help = 'Transform list in excel or CSV file. How data is '
123
+ transf_help += 'transformed is described in a configuration file. Name '
124
+ transf_help += 'of input file, output file and configuration file is '
125
+ transf_help += 'given as command line arguments.'
126
+ transf_parser = subparsers.add_parser('transform', help=transf_help,
127
+ epilog=USAGE_ORDER,
128
+ description=transf_help +
129
+ SEE_MAIN_HELP)
130
+ transf_parser.set_defaults(func=rfmt_cmd)
131
+ transf_parser.add_argument('-c', '--cfg', nargs=1, required=True,
132
+ help='Configuation file name to use.')
133
+ transf_parser.add_argument('-i', '--input', nargs=1,
134
+ help='Name of input file.', required=True)
135
+ transf_parser.add_argument('-o', '--output', nargs=1,
136
+ help='Name of output file to create.',
137
+ required=True)
138
+
139
+
140
+ def version_args(subparsers: SubParseAct) -> None:
141
+ """Add arguments for version sub-command."""
142
+ version_help = 'Only print versions of excel_list_transform '
143
+ version_help += 'and of main modules used by it and of Python.'
144
+ version_parser = subparsers.add_parser('version', help=version_help,
145
+ epilog=USAGE_ORDER,
146
+ description=version_help +
147
+ SEE_MAIN_HELP)
148
+ version_parser.set_defaults(func=version_cmd)
129
149
 
130
150
 
131
151
  def transform_cmd(arguments: Optional[list[str]] = None) -> None:
@@ -146,7 +166,8 @@ def transform_cmd(arguments: Optional[list[str]] = None) -> None:
146
166
  description=desc, epilog=epimain)
147
167
  subparsers = parser.add_subparsers(dest='subparser_name', required=True)
148
168
  gen_cfg_args(subparsers)
149
- rfmt_args(subparsers)
169
+ transf_args(subparsers)
170
+ version_args(subparsers)
150
171
  args = parser.parse_args(args=fixed_args)
151
172
  _ = args.func(args)
152
173
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Function for doing transform of lists excel files."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Functions for doing transform of lists excel files."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Functions for doing transform of lists excel files."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Functions for doing transform of lists excel files."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -0,0 +1,61 @@
1
+ #! /usr/local/bin/python3
2
+ """Get and print version information."""
3
+
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
+ # MIT License
6
+
7
+
8
+ import sys
9
+ from importlib.metadata import version as metadata_version
10
+ from typing import Optional, TypeAlias
11
+
12
+ VersionInfo: TypeAlias = dict[str, str]
13
+
14
+
15
+ class Version():
16
+ """Get and print version information."""
17
+
18
+ def __init__(self) -> None:
19
+ """Create version information object."""
20
+ self.versions: Optional[VersionInfo] = None
21
+
22
+ def print(self, versions: Optional[VersionInfo] = None) -> None:
23
+ """Print version information."""
24
+ if versions is None:
25
+ if self.versions is None:
26
+ self.versions = self.get()
27
+ versions = self.versions
28
+ maxlen: int = max(map(len, versions.keys()))
29
+ for key, value in versions.items():
30
+ pad = '.' * (maxlen - len(key))
31
+ print(f'{key} {pad} {value}')
32
+ if 'Python' in versions and versions['Python'] < '3.13':
33
+ pip = 'pip3'
34
+ applic = list(versions.keys())[0].replace('_', '-')
35
+ if sys.platform.startswith('win') \
36
+ or sys.platform.startswith('Win'):
37
+ pip = 'pip'
38
+ txt = '\nYou are running an old Python version.\n'
39
+ txt += 'Upgrade Python to a new version.\n'
40
+ txt += '(Download Python from https://www.python.org/downloads/)\n'
41
+ txt += 'After installing new Python, upgrade application with\n'
42
+ txt += pip + ' install --upgrade excel-list-transform\n'
43
+ if applic != 'excel-list-transform':
44
+ txt += pip + ' install --upgrade ' + applic + '\n'
45
+ txt += '\n'
46
+ print(txt)
47
+
48
+ def get(self) -> VersionInfo:
49
+ """Get version information for module and dependencies."""
50
+ if self.versions is not None:
51
+ return self.versions
52
+ versions: VersionInfo = {i: metadata_version(i)
53
+ for i in self.module_names()}
54
+ versions['Python'] = '.'.join([str(i) for i in sys.version_info])
55
+ self.versions = versions
56
+ return versions
57
+
58
+ def module_names(self) -> list[str]:
59
+ """Get list of modules to get versions for."""
60
+ return ['excel_list_transform', 'openpyxl', 'pylightxl',
61
+ 'XlsxWriter']
@@ -1,2 +0,0 @@
1
- # Copyright (c) 2024 Tom Björkholm
2
- # MIT License