tableio 0.2__tar.gz → 0.3__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 (34) hide show
  1. {tableio-0.2/tableio.egg-info → tableio-0.3}/PKG-INFO +21 -16
  2. {tableio-0.2 → tableio-0.3}/README.md +2 -2
  3. {tableio-0.2 → tableio-0.3}/README_pypi.md +16 -13
  4. {tableio-0.2 → tableio-0.3}/pyproject.toml +1 -1
  5. {tableio-0.2 → tableio-0.3}/setup.py +5 -3
  6. tableio-0.3/src/tableio/__init__.py +47 -0
  7. {tableio-0.2 → tableio-0.3}/src/tableio/capability.py +14 -0
  8. {tableio-0.2 → tableio-0.3}/src/tableio/factory.py +46 -3
  9. {tableio-0.2 → tableio-0.3}/src/tableio/reg_pkg_formats.py +6 -1
  10. {tableio-0.2 → tableio-0.3}/src/tableio/tableio.py +159 -110
  11. {tableio-0.2 → tableio-0.3}/src/tableio/tableio_excel_openpyxl.py +20 -36
  12. tableio-0.3/src/tableio/tableio_excel_pylightxl.py +709 -0
  13. tableio-0.3/src/tableio/tableio_excel_xlsxwriter.py +407 -0
  14. {tableio-0.2 → tableio-0.3}/src/tableio/tableio_excelbased.py +49 -2
  15. {tableio-0.2 → tableio-0.3}/src/tableio/tableio_ods_odfdo.py +16 -33
  16. {tableio-0.2 → tableio-0.3}/src/tableio/tableio_spreadsheetbased.py +220 -26
  17. tableio-0.3/src/tableio/tableio_types.py +61 -0
  18. {tableio-0.2 → tableio-0.3}/src/tableio/valueconversion.py +3 -2
  19. {tableio-0.2 → tableio-0.3/tableio.egg-info}/PKG-INFO +21 -16
  20. {tableio-0.2 → tableio-0.3}/tableio.egg-info/SOURCES.txt +3 -0
  21. {tableio-0.2 → tableio-0.3}/tableio.egg-info/requires.txt +4 -2
  22. tableio-0.2/src/tableio/__init__.py +0 -6
  23. {tableio-0.2 → tableio-0.3}/LICENSE.txt +0 -0
  24. {tableio-0.2 → tableio-0.3}/setup.cfg +0 -0
  25. {tableio-0.2 → tableio-0.3}/src/tableio/color.py +0 -0
  26. {tableio-0.2 → tableio-0.3}/src/tableio/optional_args.py +0 -0
  27. {tableio-0.2 → tableio-0.3}/src/tableio/py.typed +0 -0
  28. {tableio-0.2 → tableio-0.3}/src/tableio/tableio_csv.py +0 -0
  29. {tableio-0.2 → tableio-0.3}/src/tableio/tableio_mformat.py +0 -0
  30. {tableio-0.2 → tableio-0.3}/src/tableio/tableio_mformatbased.py +0 -0
  31. {tableio-0.2 → tableio-0.3}/src/tableio/tableio_textbased.py +0 -0
  32. {tableio-0.2 → tableio-0.3}/src/tableio/value_type.py +0 -0
  33. {tableio-0.2 → tableio-0.3}/tableio.egg-info/dependency_links.txt +0 -0
  34. {tableio-0.2 → tableio-0.3}/tableio.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tableio
3
- Version: 0.2
3
+ Version: 0.3
4
4
  Summary: Uniform way to write table data to and read from different file formats
5
5
  Author: Tom Björkholm
6
6
  Author-email: Tom Björkholm <klausuler_linnet0q@icloud.com>
@@ -13,12 +13,14 @@ Description-Content-Type: text/markdown
13
13
  License-File: LICENSE.txt
14
14
  Requires-Dist: pip>=26.0.1
15
15
  Requires-Dist: setuptools>=82.0.1
16
- Requires-Dist: build>=1.4.0
16
+ Requires-Dist: build>=1.4.2
17
17
  Requires-Dist: wheel>=0.46.3
18
18
  Requires-Dist: mformat-ext>=0.6
19
19
  Requires-Dist: openpyxl>=3.1.5
20
20
  Requires-Dist: types-openpyxl>=3.1.5.20260322
21
- Requires-Dist: odfdo>=3.22.1
21
+ Requires-Dist: odfdo>=3.22.3
22
+ Requires-Dist: xlsxwriter>=3.2.9
23
+ Requires-Dist: pylightxl>=1.61
22
24
  Dynamic: author
23
25
  Dynamic: license-file
24
26
  Dynamic: requires-dist
@@ -30,15 +32,15 @@ The tableio package contains a number of classes providing a uniform way for
30
32
  a python program to write table data (rows of columns) to and read table data
31
33
  from a number of different common file formats.
32
34
 
33
- An increasing number of users want output from programs to de in a format
35
+ An increasing number of users want output from programs to be in a format
34
36
  like a spreadsheet, and not the old fashoned raw text files. Similarly,
35
37
  many users want the data they feed into programs to be in a particular format
36
- (like a spreadsheet). The tableio packade tries to make it easier for the
38
+ (like a spreadsheet). The tableio package tries to make it easier for the
37
39
  programmer to fullfil requests like that.
38
40
 
39
- The primary intended use is for text output from a python program, where the
40
- programmer would like the user to be able to select the input and output file
41
- formats.
41
+ The primary intended use is for data table output from a python program
42
+ and data table input to a python program, where the programmer would like
43
+ the user to be able to select the input and output file formats.
42
44
 
43
45
  The support for spreadsheets is for reading and writing data. There is no
44
46
  intention to support reading or writing formulas. There is no support for
@@ -68,6 +70,8 @@ The currently supported formats are:
68
70
  |-------------|----------------|-----------|----------|
69
71
  | CSV | csv | yes | yes |
70
72
  | Excel | OpenPyXL | yes | yes |
73
+ | Excel | XlsxWriter | yes | - |
74
+ | Excel | pylightxl | yes | yes |
71
75
  | ODS | odfdo | yes | yes |
72
76
  | HTML | mformat | yes | - |
73
77
  | LaTeX | mformat | yes | - |
@@ -109,6 +113,8 @@ The main features are:
109
113
  - writing a table to a specific location in a spreadsheet (specified by a box)
110
114
  - reading table data from a specific location in a spreadsheet (specified by a box)
111
115
  - using multiple sheets in spreadsheets
116
+ - finding location where some data is present in spreadsheet and doing modifications
117
+ at that position or at positions relative to that position.
112
118
 
113
119
  ## Example programs
114
120
 
@@ -118,8 +124,6 @@ example programs:
118
124
 
119
125
  ## API documentation
120
126
 
121
- Be aware that this is still in early development. The APIs may change between versions.
122
-
123
127
  You can find the public API documentation at [https://bitbucket.org/tom-bjorkholm/table-io/src/master/doc/api.md](https://bitbucket.org/tom-bjorkholm/table-io/src/master/doc/api.md)
124
128
 
125
129
  You can find the protected API documentation at [https://bitbucket.org/tom-bjorkholm/table-io/src/master/doc/protected_api.md](https://bitbucket.org/tom-bjorkholm/table-io/src/master/doc/protected_api.md)
@@ -132,15 +136,16 @@ a better start by reading the examples.
132
136
 
133
137
  ## Version history
134
138
 
135
- | Version | Date | Python version | Comment |
136
- |---------|-------------|----------------|----------------------------|
137
- | 0.2 | 2026 Mar 28 | 3.12 or newer | More features, API changes |
138
- | 0.1 | 2026 Mar 23 | 3.12 or newer | First released version |
139
+ | Version | Date | Python version | Comment |
140
+ |---------|-------------|----------------|-----------------------------|
141
+ | 0.3 | 2023 Apr 01 | 3.12 or newer | Improved API, more backends |
142
+ | 0.2 | 2026 Mar 28 | 3.12 or newer | More features, API changes |
143
+ | 0.1 | 2026 Mar 23 | 3.12 or newer | First released version |
139
144
 
140
145
  ## Test summary
141
146
 
142
- - Test result: 869 passed in 11s
147
+ - Test result: 1010 passed in 14s
143
148
  - No flake8 warnings.
144
149
  - No mypy errors found.
145
- - Built version(s): 0.2
150
+ - Built version(s): 0.3
146
151
  - Build and test using Python 3.14.3
@@ -93,8 +93,8 @@ information about the build system. This README can also be viewed at
93
93
 
94
94
  ## Test summary
95
95
 
96
- - Test result: 869 passed in 11s
96
+ - Test result: 1010 passed in 14s
97
97
  - No flake8 warnings.
98
98
  - No mypy errors found.
99
- - Built version(s): 0.2
99
+ - Built version(s): 0.3
100
100
  - Build and test using Python 3.14.3
@@ -4,15 +4,15 @@ The tableio package contains a number of classes providing a uniform way for
4
4
  a python program to write table data (rows of columns) to and read table data
5
5
  from a number of different common file formats.
6
6
 
7
- An increasing number of users want output from programs to de in a format
7
+ An increasing number of users want output from programs to be in a format
8
8
  like a spreadsheet, and not the old fashoned raw text files. Similarly,
9
9
  many users want the data they feed into programs to be in a particular format
10
- (like a spreadsheet). The tableio packade tries to make it easier for the
10
+ (like a spreadsheet). The tableio package tries to make it easier for the
11
11
  programmer to fullfil requests like that.
12
12
 
13
- The primary intended use is for text output from a python program, where the
14
- programmer would like the user to be able to select the input and output file
15
- formats.
13
+ The primary intended use is for data table output from a python program
14
+ and data table input to a python program, where the programmer would like
15
+ the user to be able to select the input and output file formats.
16
16
 
17
17
  The support for spreadsheets is for reading and writing data. There is no
18
18
  intention to support reading or writing formulas. There is no support for
@@ -42,6 +42,8 @@ The currently supported formats are:
42
42
  |-------------|----------------|-----------|----------|
43
43
  | CSV | csv | yes | yes |
44
44
  | Excel | OpenPyXL | yes | yes |
45
+ | Excel | XlsxWriter | yes | - |
46
+ | Excel | pylightxl | yes | yes |
45
47
  | ODS | odfdo | yes | yes |
46
48
  | HTML | mformat | yes | - |
47
49
  | LaTeX | mformat | yes | - |
@@ -83,6 +85,8 @@ The main features are:
83
85
  - writing a table to a specific location in a spreadsheet (specified by a box)
84
86
  - reading table data from a specific location in a spreadsheet (specified by a box)
85
87
  - using multiple sheets in spreadsheets
88
+ - finding location where some data is present in spreadsheet and doing modifications
89
+ at that position or at positions relative to that position.
86
90
 
87
91
  ## Example programs
88
92
 
@@ -92,8 +96,6 @@ example programs:
92
96
 
93
97
  ## API documentation
94
98
 
95
- Be aware that this is still in early development. The APIs may change between versions.
96
-
97
99
  You can find the public API documentation at [https://bitbucket.org/tom-bjorkholm/table-io/src/master/doc/api.md](https://bitbucket.org/tom-bjorkholm/table-io/src/master/doc/api.md)
98
100
 
99
101
  You can find the protected API documentation at [https://bitbucket.org/tom-bjorkholm/table-io/src/master/doc/protected_api.md](https://bitbucket.org/tom-bjorkholm/table-io/src/master/doc/protected_api.md)
@@ -106,15 +108,16 @@ a better start by reading the examples.
106
108
 
107
109
  ## Version history
108
110
 
109
- | Version | Date | Python version | Comment |
110
- |---------|-------------|----------------|----------------------------|
111
- | 0.2 | 2026 Mar 28 | 3.12 or newer | More features, API changes |
112
- | 0.1 | 2026 Mar 23 | 3.12 or newer | First released version |
111
+ | Version | Date | Python version | Comment |
112
+ |---------|-------------|----------------|-----------------------------|
113
+ | 0.3 | 2023 Apr 01 | 3.12 or newer | Improved API, more backends |
114
+ | 0.2 | 2026 Mar 28 | 3.12 or newer | More features, API changes |
115
+ | 0.1 | 2026 Mar 23 | 3.12 or newer | First released version |
113
116
 
114
117
  ## Test summary
115
118
 
116
- - Test result: 869 passed in 11s
119
+ - Test result: 1010 passed in 14s
117
120
  - No flake8 warnings.
118
121
  - No mypy errors found.
119
- - Built version(s): 0.2
122
+ - Built version(s): 0.3
120
123
  - Build and test using Python 3.14.3
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "tableio"
7
- version = "0.2"
7
+ version = "0.3"
8
8
  authors = [
9
9
  { name="Tom Björkholm", email="klausuler_linnet0q@icloud.com" },
10
10
  ]
@@ -5,7 +5,7 @@ from setuptools import setup
5
5
 
6
6
  setup(
7
7
  name='tableio',
8
- version='0.2',
8
+ version='0.3',
9
9
  description='Uniform way to write table data to and read from different ' \
10
10
  'file formats',
11
11
  author='Tom Björkholm',
@@ -17,11 +17,13 @@ setup(
17
17
  install_requires=[ # pylint: disable=duplicate-code
18
18
  'pip >= 26.0.1',
19
19
  'setuptools >= 82.0.1',
20
- 'build >= 1.4.0',
20
+ 'build >= 1.4.2',
21
21
  'wheel >= 0.46.3',
22
22
  'mformat-ext >= 0.6',
23
23
  'openpyxl >= 3.1.5',
24
24
  'types-openpyxl >= 3.1.5.20260322',
25
- 'odfdo >= 3.22.1'
25
+ 'odfdo >= 3.22.3',
26
+ 'xlsxwriter >= 3.2.9',
27
+ 'pylightxl >= 1.61'
26
28
  ]
27
29
  )
@@ -0,0 +1,47 @@
1
+ #! /usr/local/bin/python3
2
+ """Curated top-level public API for the tableio package."""
3
+
4
+ # Copyright (c) 2026 Tom Björkholm
5
+ # MIT License
6
+ #
7
+
8
+ from tableio.capability import CAP_IGNORABLE, CAP_NEEDED, CAP_NOT_USED, \
9
+ Capabilities
10
+ from tableio.color import Color
11
+ from tableio.factory import create_tableio, filter_args_tableio, \
12
+ list_implementations_tableio, list_registered_tableio
13
+ from tableio.optional_args import CsvDialect, OptionalArgs, OptionalArgsDict
14
+ from tableio.tableio import Box, FileAccess, Position, TableIO
15
+ from tableio.value_type import CellT, DictData, DictDataMap, Fmt, \
16
+ FmtDictData, FmtDictRow, FmtListData, FmtListRow, ListData, \
17
+ ListDataSeq, ReadResult, Value, ValueFmt
18
+
19
+ __all__ = ['create_tableio',
20
+ 'TableIO',
21
+ 'FileAccess',
22
+ 'Box',
23
+ 'Position',
24
+ 'OptionalArgs',
25
+ 'OptionalArgsDict',
26
+ 'Value',
27
+ 'ListData',
28
+ 'ListDataSeq',
29
+ 'DictData',
30
+ 'DictDataMap',
31
+ 'ReadResult',
32
+ 'Fmt',
33
+ 'ValueFmt',
34
+ 'FmtListRow',
35
+ 'FmtDictRow',
36
+ 'FmtListData',
37
+ 'FmtDictData',
38
+ 'CellT',
39
+ 'Color',
40
+ 'Capabilities',
41
+ 'CAP_NEEDED',
42
+ 'CAP_NOT_USED',
43
+ 'CAP_IGNORABLE',
44
+ 'filter_args_tableio',
45
+ 'list_registered_tableio',
46
+ 'list_implementations_tableio',
47
+ 'CsvDialect']
@@ -87,6 +87,9 @@ class Capabilities(NamedTuple):
87
87
  multi_sheet: SingleCapability = SingleCapability()
88
88
  """The reader/writer class can read from or write to multiple sheets."""
89
89
 
90
+ can_find_value_position: SingleCapability = SingleCapability()
91
+ """The reader/writer class can find the position of a value."""
92
+
90
93
 
91
94
  def single_capability_match(offered: SingleCapability,
92
95
  will_use: SingleCapability,
@@ -233,3 +236,14 @@ CAP_UNSUPPORTED = SingleCapability(supported=False,
233
236
  different location would not make sense. Thus the only sensible thing
234
237
  to do is to raise an exception.
235
238
  """
239
+
240
+ CAP_ALL_IMPLEMENTED = Capabilities(can_read=CAP_IMPLEMENTED,
241
+ can_write=CAP_IMPLEMENTED,
242
+ can_fmt_row=CAP_IMPLEMENTED,
243
+ can_fmt_value=CAP_IMPLEMENTED,
244
+ filtered_data_range=CAP_IMPLEMENTED,
245
+ can_write_box=CAP_IMPLEMENTED,
246
+ can_read_box=CAP_IMPLEMENTED,
247
+ can_write_highlight=CAP_IMPLEMENTED,
248
+ multi_sheet=CAP_IMPLEMENTED,
249
+ can_find_value_position=CAP_IMPLEMENTED)
@@ -51,6 +51,37 @@ class TableIOFactoryNoCapabilityMatch(ValueError):
51
51
  """
52
52
 
53
53
 
54
+ class InsufficientCapabilities(ValueError):
55
+ """Raised when requested capabilities contradict requested file access.
56
+
57
+ Error raised when the caller supplies both file access and an explicit
58
+ Capabilities object, but the requested capabilities do not include the
59
+ capability implied by that access mode. For example, READ requires
60
+ can_read, CREATE requires can_write, and UPDATE requires both.
61
+ """
62
+
63
+
64
+ def _check_capabilities_for_file_access(
65
+ file_access: FileAccess,
66
+ capabilities: Optional[Capabilities]) -> None:
67
+ """Raise if explicit capabilities not enough for requested access mode."""
68
+ if capabilities is None:
69
+ return
70
+ if file_access == FileAccess.READ and not capabilities.can_read.supported:
71
+ msg = 'FileAccess.READ requires can_read capability.'
72
+ raise InsufficientCapabilities(msg)
73
+ if file_access == FileAccess.CREATE and \
74
+ not capabilities.can_write.supported:
75
+ msg = 'FileAccess.CREATE requires can_write capability.'
76
+ raise InsufficientCapabilities(msg)
77
+ if file_access == FileAccess.UPDATE and (
78
+ not capabilities.can_write.supported or
79
+ not capabilities.can_read.supported):
80
+ msg = 'FileAccess.UPDATE requires both can_read and '
81
+ msg += 'can_write capabilities.'
82
+ raise InsufficientCapabilities(msg)
83
+
84
+
54
85
  @total_ordering
55
86
  class ImplPrio(NamedTuple):
56
87
  """Priority of an implementation."""
@@ -339,6 +370,7 @@ class TableIOFactory:
339
370
  An instance of the requested TableIO subclass.
340
371
  Intended to be used as context manager, using a with statement.
341
372
  Raises:
373
+ InsufficientCapabilities: If capabilities contradict file_access.
342
374
  TableIOFactoryNoSuchError: If the format_name is not registered
343
375
  or the implementation name is not
344
376
  registered.
@@ -357,7 +389,17 @@ class TableIOFactory:
357
389
  file_access: FileAccess, args: OptionalArgs = None,
358
390
  implementation: Optional[str] = None,
359
391
  capabilities: Optional[Capabilities] = None) -> TableIO:
360
- """Internally create an instance of a registered subclass."""
392
+ """Internally create an instance of a registered subclass.
393
+
394
+ Raises:
395
+ InsufficientCapabilities: If capabilities contradict file_access.
396
+ TableIOFactoryNoSuchError: If the format_name is not registered
397
+ or the implementation name is not
398
+ registered.
399
+ TableIOFactoryNoCapabilityMatch: If the capabilities cannot be
400
+ matched to any implementation.
401
+ """
402
+ _check_capabilities_for_file_access(file_access, capabilities)
361
403
  correct_name: Optional[str] = None
362
404
  if format_name in self._formats:
363
405
  correct_name = format_name
@@ -371,8 +413,8 @@ class TableIOFactory:
371
413
  )
372
414
  assert correct_name is not None
373
415
  format_info: FactoryFormatInfo = self._formats[correct_name]
374
- best_matches = format_info.best_match_names(capabilities=capabilities,
375
- empty_is_ok=False)
416
+ best_matches = format_info.best_match_names(
417
+ capabilities=capabilities, empty_is_ok=False)
376
418
  if implementation is not None:
377
419
  fikeys = list(format_info._registry.keys()) # pylint: disable=protected-access # noqa: E501
378
420
  if implementation not in fikeys:
@@ -666,6 +708,7 @@ def create_tableio(format_name: str, # pylint: disable=too-many-arguments, too-
666
708
  Returns:
667
709
  An instance of the requested TableIO subclass.
668
710
  Raises:
711
+ InsufficientCapabilities: If capabilities contradict file_access.
669
712
  TableIOFactoryNoSuchError: If the format_name or implementation
670
713
  name is not registered.
671
714
  TableIOFactoryNoCapabilityMatch: If the capabilities cannot be
@@ -16,6 +16,8 @@ from tableio.tableio_mformat import TableIOMformatHtml, TableIOMformatMd, \
16
16
  TableIOMformatRtf
17
17
  from tableio.tableio_csv import TableIOCsv
18
18
  from tableio.tableio_excel_openpyxl import TableIOExcelOpenPyXL
19
+ from tableio.tableio_excel_pylightxl import TableIOExcelPylightxl
20
+ from tableio.tableio_excel_xlsxwriter import TableIOExcelXlsxWriter
19
21
  from tableio.tableio_ods_odfdo import TableIOOdsOdfdo
20
22
  from tableio.tableio import TableIO
21
23
 
@@ -27,5 +29,8 @@ def register_formats_in_pkg() -> list[type[TableIO]]:
27
29
  TableIOMformatLatex, TableIOMformatDocx,
28
30
  TableIOMformatOdt, TableIOMformatPdf,
29
31
  TableIOMformatRtf, TableIOCsv,
30
- TableIOExcelOpenPyXL, TableIOOdsOdfdo]
32
+ TableIOExcelOpenPyXL,
33
+ TableIOExcelPylightxl,
34
+ TableIOExcelXlsxWriter,
35
+ TableIOOdsOdfdo]
31
36
  return ret