numbers-parser 4.19.0__tar.gz → 4.20.0__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.
- numbers_parser-4.20.0/LICENSE.rst +49 -0
- {numbers_parser-4.19.0/src/numbers_parser.egg-info → numbers_parser-4.20.0}/PKG-INFO +62 -40
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/README.md +58 -38
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/pyproject.toml +17 -12
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/_cat_numbers.py +11 -13
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/_csv2numbers.py +10 -5
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/_unpack_numbers.py +3 -2
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/cell.py +226 -112
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/constants.py +24 -2
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/containers.py +22 -13
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/document.py +310 -115
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/exceptions.py +1 -1
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TNArchives_pb2.py +27 -27
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TNArchives_sos_pb2.py +6 -6
- numbers_parser-4.20.0/src/numbers_parser/generated/TNCommandArchives_pb2.py +133 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TNCommandArchives_sos_pb2.py +3 -3
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSAArchives_pb2.py +3 -3
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSAArchives_sos_pb2.py +3 -3
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSACommandArchives_sos_pb2.py +3 -3
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSCEArchives_pb2.py +3 -3
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSCH3DArchives_pb2.py +3 -3
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSCHArchives_Common_pb2.py +3 -3
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSCHArchives_GEN_pb2.py +3 -3
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSCHArchives_pb2.py +3 -3
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSCHArchives_sos_pb2.py +3 -3
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSCHCommandArchives_pb2.py +3 -3
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSCHPreUFFArchives_pb2.py +3 -3
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSCKArchives_pb2.py +3 -3
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSCKArchives_sos_pb2.py +3 -3
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSDArchives_pb2.py +85 -85
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSDArchives_sos_pb2.py +3 -3
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSDCommandArchives_pb2.py +3 -3
- numbers_parser-4.20.0/src/numbers_parser/generated/TSKArchives_pb2.py +161 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSPArchiveMessages_pb2.py +3 -3
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSPDatabaseMessages_pb2.py +3 -3
- numbers_parser-4.20.0/src/numbers_parser/generated/TSPMessages_pb2.py +137 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSSArchives_pb2.py +39 -39
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSSArchives_sos_pb2.py +3 -3
- numbers_parser-4.20.0/src/numbers_parser/generated/TSTArchives_pb2.py +444 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSTArchives_sos_pb2.py +3 -3
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSTCommandArchives_pb2.py +57 -57
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSTStylePropertyArchiving_pb2.py +3 -3
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSWPArchives_pb2.py +105 -103
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/TSWPArchives_sos_pb2.py +3 -3
- numbers_parser-4.20.0/src/numbers_parser/generated/TSWPCommandArchives_pb2.py +140 -0
- numbers_parser-4.20.0/src/numbers_parser/generated/fontmap.py +3915 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/functionmap.py +17 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/mapping.py +5 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/iwafile.py +2 -2
- numbers_parser-4.20.0/src/numbers_parser/iwork.py +445 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/model.py +47 -77
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/xrefs.py +20 -8
- {numbers_parser-4.19.0 → numbers_parser-4.20.0/src/numbers_parser.egg-info}/PKG-INFO +62 -40
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser.egg-info/SOURCES.txt +1 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser.egg-info/requires.txt +3 -1
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_borders.py +21 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_cat_numbers.py +36 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_coverage.py +57 -4
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_create_cells.py +31 -2
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_csv2numbers.py +12 -3
- numbers_parser-4.20.0/tests/test_encrypted.py +162 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_formatting.py +8 -8
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_issues.py +68 -18
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_local_docs.py +33 -1
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_merges.py +46 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_save.py +17 -5
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_slices.py +82 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_styles.py +41 -3
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_unpack_numbers.py +40 -0
- numbers_parser-4.19.0/LICENSE.rst +0 -16
- numbers_parser-4.19.0/src/numbers_parser/generated/TNCommandArchives_pb2.py +0 -129
- numbers_parser-4.19.0/src/numbers_parser/generated/TSKArchives_pb2.py +0 -157
- numbers_parser-4.19.0/src/numbers_parser/generated/TSPMessages_pb2.py +0 -137
- numbers_parser-4.19.0/src/numbers_parser/generated/TSTArchives_pb2.py +0 -442
- numbers_parser-4.19.0/src/numbers_parser/generated/TSWPCommandArchives_pb2.py +0 -144
- numbers_parser-4.19.0/src/numbers_parser/generated/fontmap.py +0 -567
- numbers_parser-4.19.0/src/numbers_parser/iwork.py +0 -245
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/setup.cfg +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/__init__.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/bullets.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/currencies.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/data/empty.numbers +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/experimental.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/formula.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/generated/__init__.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/numbers_cache.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/numbers_uuid.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser/roman.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser.egg-info/dependency_links.txt +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser.egg-info/entry_points.txt +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/src/numbers_parser.egg-info/top_level.txt +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_all_formulas.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_api_change.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_bullets.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_categories.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_currency.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_folder.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_formulas.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_large.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_memory_leaks.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_package.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_properties.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_roman.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_table_size.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_tables.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_unsupported.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_uuids.py +0 -0
- {numbers_parser-4.19.0 → numbers_parser-4.20.0}/tests/test_version.py +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
Copyright 2021 Jon Connell
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
4
|
+
and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
5
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
6
|
+
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
7
|
+
furnished to do so, subject to the following conditions:
|
|
8
|
+
|
|
9
|
+
The above copyright notice and this permission notice shall be included in all copies or
|
|
10
|
+
substantial portions of the Software.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
|
13
|
+
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
14
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
15
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
|
|
17
|
+
|
|
18
|
+
Third-party acknowledgments
|
|
19
|
+
---------------------------
|
|
20
|
+
|
|
21
|
+
The following third-party projects are acknowledged in `docs/credits.rst <docs/credits.rst>`__.
|
|
22
|
+
The full license texts and original copyright notices for these dependencies are included
|
|
23
|
+
in the `licenses <licenses>`__ directory of this repository.
|
|
24
|
+
|
|
25
|
+
* `keynote-parser <https://github.com/psobot/keynote-parser>`__ by Peter Sobot
|
|
26
|
+
is licensed under the MIT License. See `licenses/keynote-parser.txt <licenses/keynote-parser.txt>`__
|
|
27
|
+
|
|
28
|
+
* `Excel reference parsing from <https://github.com/jmcnamara/XlsxWriter>`__ by John McNamara
|
|
29
|
+
is licensed under the BSD 2-Clause License. `licenses/XlsxWriter.txt <licenses/XlsxWriter.txt>`__.
|
|
30
|
+
|
|
31
|
+
* `iWorkFileFormat <https://github.com/obriensp/iWorkFileFormat>`__ by Sean Patrick O'Brien
|
|
32
|
+
is licensed under the MIT License. See `licenses/iWorkFileFormat.txt <licenses/iWorkFileFormat.txt>`__.
|
|
33
|
+
|
|
34
|
+
* `Stingray-Reader <https://github.com/slott56/Stingray-Reader>`__ by Steven Lott
|
|
35
|
+
is licensed under CC BY-NC-SA 4.0.
|
|
36
|
+
|
|
37
|
+
* `fast-formula-parser <https://github.com/LesterLyu/fast-formula-parser>`__ by Dishu (Lester) Lyu
|
|
38
|
+
is licensed under the MIT License. See `licenses/fast-formula-parser.txt <licenses/fast-formula-parser.txt>`__.
|
|
39
|
+
|
|
40
|
+
* `SheetJS <https://github.com/SheetJS/sheetjs>`__
|
|
41
|
+
is licensed under the Apache License 2.0. See `licenses/SheetJS.txt <licenses/SheetJS.txt>`__.
|
|
42
|
+
|
|
43
|
+
`docs/api/file-format.rst <docs/api/file-format.rst>`__ is a derivative work based on the
|
|
44
|
+
iWork format research by Sean Patrick O'Brien, the Numbers/IWA documentation in
|
|
45
|
+
Stingray-Reader, and SheetJS format research. It is licensed under
|
|
46
|
+
`CC BY-NC-SA 4.0 <https://creativecommons.org/licenses/by-nc-sa/4.0/>`__,
|
|
47
|
+
including its attribution and ShareAlike terms. This file's license is an
|
|
48
|
+
exception to the project's default MIT license; other third-party materials
|
|
49
|
+
remain under their respective licenses.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: numbers-parser
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.20.0
|
|
4
4
|
Summary: Read and write Apple Numbers spreadsheets
|
|
5
5
|
Author-email: Jon Connell <python@figsandfudge.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -13,13 +13,15 @@ Requires-Python: >=3.10
|
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE.rst
|
|
15
15
|
Requires-Dist: compact-json>=1.1.3
|
|
16
|
-
Requires-Dist: protobuf>=7.
|
|
16
|
+
Requires-Dist: protobuf>=7.36.0
|
|
17
17
|
Requires-Dist: python-snappy>=0.7
|
|
18
18
|
Requires-Dist: sigfig>=1.3.3
|
|
19
19
|
Requires-Dist: setuptools>=70.0.0
|
|
20
20
|
Requires-Dist: importlib-resources>=6.1
|
|
21
21
|
Requires-Dist: enum-tools>=0.11
|
|
22
22
|
Requires-Dist: python-dateutil>=2.9.0.post0
|
|
23
|
+
Requires-Dist: security>=1.3.1
|
|
24
|
+
Requires-Dist: cryptography>=50.0.1
|
|
23
25
|
Dynamic: license-file
|
|
24
26
|
|
|
25
27
|
# numbers-parser
|
|
@@ -34,7 +36,7 @@ It supports and is tested against Python versions from 3.10 onwards. It is not c
|
|
|
34
36
|
|
|
35
37
|
A pre-requisite for this package is [python-snappy](https://pypi.org/project/python-snappy/) which will be installed by Python automatically, but python-snappy also requires binary libraries for snappy compression.
|
|
36
38
|
|
|
37
|
-
The most straightforward way to install the binary dependencies is to use [Homebrew](https://brew.sh) and source Python from Homebrew rather than from macOS as described in the [python-snappy github](https://github.com/andrix/python-snappy). Using [pipx](https://pipx.pypa.io/stable/
|
|
39
|
+
The most straightforward way to install the binary dependencies is to use [Homebrew](https://brew.sh) and source Python from Homebrew rather than from macOS as described in the [python-snappy github](https://github.com/andrix/python-snappy). Using [pipx](https://pipx.pypa.io/stable/how-to/install-pipx.html) for package management is also strongly recommended:
|
|
38
40
|
|
|
39
41
|
```bash
|
|
40
42
|
brew install snappy python3 pipx
|
|
@@ -65,8 +67,14 @@ Reading documents:
|
|
|
65
67
|
>>> rows = tables[0].rows()
|
|
66
68
|
```
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
Encrypted documents are also supported for reading:
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
>>> from numbers_parser import Document
|
|
74
|
+
>>> doc = Document("mydoc.numbers", password="s3cr3t")
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Sheets and tables are iterables that can be indexed using either an integer index or using the name of the sheet/table:
|
|
70
78
|
|
|
71
79
|
```python
|
|
72
80
|
>>> doc.sheets[0].name
|
|
@@ -74,30 +82,26 @@ integer index or using the name of the sheet/table:
|
|
|
74
82
|
>>> doc.sheets["Sheet 1"].name
|
|
75
83
|
'Sheet 1'
|
|
76
84
|
>>> doc.sheets[0].tables[0].name
|
|
77
|
-
'
|
|
78
|
-
>>> doc.sheets[0].tables["
|
|
79
|
-
'
|
|
85
|
+
'Categories'
|
|
86
|
+
>>> doc.sheets[0].tables["Categories"].name
|
|
87
|
+
'Categories'
|
|
80
88
|
```
|
|
81
89
|
|
|
82
|
-
`Table` objects have a `rows` method which contains a nested list
|
|
83
|
-
with an entry for each row of the table. Each row is itself a list of
|
|
84
|
-
the column values.
|
|
90
|
+
`Table` objects have a `rows` method which contains a nested list with an entry for each row of the table. Each row is itself a list of the column values.
|
|
85
91
|
|
|
86
92
|
```python
|
|
87
|
-
>>> data = sheets["Sheet 1"].tables["
|
|
93
|
+
>>> data = doc.sheets["Sheet 1"].tables["Examples"].rows()
|
|
88
94
|
>>> data[0][0]
|
|
89
|
-
|
|
95
|
+
numbers_parser.cell.EmptyCell(sheet_name='Sheet 1', table_name='Examples', value='None', row=0, col=0)
|
|
90
96
|
>>> data[1][0]
|
|
91
|
-
|
|
97
|
+
numbers_parser.cell.TextCell(sheet_name='Sheet 1', table_name='Examples', value='Debit', row=1, col=0)
|
|
92
98
|
>>> data[1][0].value
|
|
93
99
|
'Debit'
|
|
94
100
|
```
|
|
95
101
|
|
|
96
102
|
### Cell Data
|
|
97
103
|
|
|
98
|
-
Cells are objects with a common base class of `Cell`. All cell types
|
|
99
|
-
have a property `value` which returns the contents of the cell as a
|
|
100
|
-
python datatype. Available cell types are:
|
|
104
|
+
Cells are objects with a common base class of `Cell`. All cell types have a property `value` which returns the contents of the cell as a python datatype. Available cell types are:
|
|
101
105
|
|
|
102
106
|
| Cell type | value type | Additional properties |
|
|
103
107
|
|--------------|----------------------|--------------------------------------------------------------------------------------------------------|
|
|
@@ -115,11 +119,11 @@ Cell references can be either zero-offset row/column integers or an Excel/Number
|
|
|
115
119
|
|
|
116
120
|
```python
|
|
117
121
|
>>> table.cell(1,0)
|
|
118
|
-
|
|
122
|
+
numbers_parser.cell.TextCell(sheet_name='Sheet 1', table_name='Examples', value='Debit', row=1, col=0)
|
|
119
123
|
>>> table.cell(1,0).value
|
|
120
124
|
'Debit'
|
|
121
125
|
>>> table.cell("B2")
|
|
122
|
-
|
|
126
|
+
numbers_parser.cell.NumberCell(sheet_name='Sheet 1', table_name='Examples', value='1234.5', row=1, col=1)
|
|
123
127
|
>>> table.cell("B2").value
|
|
124
128
|
1234.5
|
|
125
129
|
>>> table.cell("B2").formatted_value
|
|
@@ -133,7 +137,7 @@ Since the return value of `rows()` is a list of lists, you can pass this directl
|
|
|
133
137
|
```python
|
|
134
138
|
import pandas as pd
|
|
135
139
|
|
|
136
|
-
doc = Document("
|
|
140
|
+
doc = Document("mydoc.numbers")
|
|
137
141
|
sheets = doc.sheets
|
|
138
142
|
tables = sheets[0].tables
|
|
139
143
|
data = tables[0].rows(values_only=True)
|
|
@@ -147,13 +151,19 @@ Whilst support for writing numbers files has been stable since version 3.4.0, yo
|
|
|
147
151
|
Cell values are written using [Table.write()](https://masaccio.github.io/numbers-parser/api/table.html#numbers_parser.Table.write) and `numbers-parser` will automatically create empty rows and columns for any cell references that are out of range of the current table.
|
|
148
152
|
|
|
149
153
|
```python
|
|
150
|
-
doc = Document("
|
|
154
|
+
doc = Document("mydoc.numbers")
|
|
151
155
|
sheets = doc.sheets
|
|
152
156
|
tables = sheets[0].tables
|
|
153
157
|
table = tables[0]
|
|
154
158
|
table.write(1, 1, "This is new text")
|
|
155
159
|
table.write("B7", datetime(2020, 12, 25))
|
|
156
|
-
doc.save("
|
|
160
|
+
doc.save("mydoc.numbers")
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Encrypted documents are not automatically re-saved with encryption and you must specify a password on save:
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
doc.save("mydoc.numbers", password="s3cr3t")
|
|
157
167
|
```
|
|
158
168
|
|
|
159
169
|
Additional tables and worksheets can be added to a `Document` before saving using [Document.add_sheet()](https://masaccio.github.io/numbers-parser/api/document.html#numbers_parser.Document.add_sheet) and [Sheet.add_table()](https://masaccio.github.io/numbers-parser/api/sheet.html#numbers_parser.Sheet.add_table) respectively:
|
|
@@ -166,7 +176,7 @@ table = sheet.tables["New Table"]
|
|
|
166
176
|
table.write(1, 1, 1000)
|
|
167
177
|
table.write(1, 2, 2000)
|
|
168
178
|
table.write(1, 3, 3000)
|
|
169
|
-
doc.save("
|
|
179
|
+
doc.save("mydoc.numbers")
|
|
170
180
|
```
|
|
171
181
|
|
|
172
182
|
### Styles
|
|
@@ -217,8 +227,8 @@ table.set_cell_formatting(
|
|
|
217
227
|
date_time_format="EEEE, d MMMM yyyy"
|
|
218
228
|
)
|
|
219
229
|
table.set_cell_formatting(
|
|
220
|
-
|
|
221
|
-
|
|
230
|
+
1,
|
|
231
|
+
1,
|
|
222
232
|
"number",
|
|
223
233
|
decimal_places=3,
|
|
224
234
|
negative_style=NegativeNumberStyle.RED
|
|
@@ -231,7 +241,7 @@ Custom formats are shared across a Document and can be applied to multiple cells
|
|
|
231
241
|
long_date = doc.add_custom_format(
|
|
232
242
|
name="Long Date",
|
|
233
243
|
type="datetime",
|
|
234
|
-
|
|
244
|
+
format="EEEE, d MMMM yyyy"
|
|
235
245
|
)
|
|
236
246
|
table.set_cell_formatting("C1", "custom", format=long_date)
|
|
237
247
|
```
|
|
@@ -285,6 +295,7 @@ options:
|
|
|
285
295
|
Names of sheet(s) to include in export
|
|
286
296
|
-t TABLE, --table TABLE
|
|
287
297
|
Names of table(s) to include in export
|
|
298
|
+
--password PASSWORD Password for encrypted documents
|
|
288
299
|
--debug Enable debug logging
|
|
289
300
|
```
|
|
290
301
|
|
|
@@ -294,7 +305,7 @@ Note: `--formatting` will return different capitalization for 12-hour times due
|
|
|
294
305
|
|
|
295
306
|
This script converts Excel-compatible CSV files into Numbers documents. Output files can optionally be provided, but is none are provided, the output is created by replacing the input’s files suffix with .numbers. For example:
|
|
296
307
|
|
|
297
|
-
```
|
|
308
|
+
```bash
|
|
298
309
|
csv2numbers file1.csv file2.csv -o file1.numbers file2.numbers
|
|
299
310
|
```
|
|
300
311
|
|
|
@@ -321,6 +332,7 @@ options:
|
|
|
321
332
|
--no-header CSV file has no header row (default: false)
|
|
322
333
|
--day-first dates are represented day first in the CSV file
|
|
323
334
|
(default: false)
|
|
335
|
+
--encoding ENCODING python-style text encoding of the CSV file (default: utf-8)
|
|
324
336
|
--date COLUMNS comma-separated list of column names/indexes to
|
|
325
337
|
parse as dates
|
|
326
338
|
--rename COLUMNS-MAP comma-separated list of column names/indexes to
|
|
@@ -333,6 +345,7 @@ options:
|
|
|
333
345
|
-o [FILENAME ...], --output [FILENAME ...]
|
|
334
346
|
output filename (default: use source file with
|
|
335
347
|
.numbers)
|
|
348
|
+
--password PASSWORD Password for encrypted documents
|
|
336
349
|
```
|
|
337
350
|
|
|
338
351
|
The following options affecting the output of the entire file. The default for each is always false.
|
|
@@ -348,7 +361,7 @@ The following options affecting the output of the entire file. The default for e
|
|
|
348
361
|
|
|
349
362
|
Delete columns using `--delete`. The names or indices of the columns to delete are specified as comma-separated values:
|
|
350
363
|
|
|
351
|
-
```
|
|
364
|
+
```bash
|
|
352
365
|
csv2numbers file1.csv --delete=Account,3
|
|
353
366
|
```
|
|
354
367
|
|
|
@@ -356,28 +369,28 @@ csv2numbers file1.csv --delete=Account,3
|
|
|
356
369
|
|
|
357
370
|
Rename columns using `--rename`. The current column name and new column name are separated by a `:` and each renaming is specified as comma-separated values:
|
|
358
371
|
|
|
359
|
-
```
|
|
372
|
+
```bash
|
|
360
373
|
csv2numbers file1.csv --rename=2:Account,"Paid In":Amount
|
|
361
374
|
```
|
|
362
375
|
|
|
363
376
|
#### Date columns
|
|
364
377
|
|
|
365
|
-
The `--date` option identifies a comma-separated list of columns that should be parsed as dates. Use `--day-first` where the day and month is ambiguous
|
|
378
|
+
The `--date` option identifies a comma-separated list of columns that should be parsed as dates. Use `--day-first` where the day and month is ambiguous and the day comes first rather than the month.
|
|
366
379
|
|
|
367
380
|
#### Transforming columns
|
|
368
381
|
|
|
369
|
-
Columns can be merged and new columns created using simple functions. The –transform option takes a comma-
|
|
382
|
+
Columns can be merged and new columns created using simple functions. The –transform option takes a comma-separated list of transformations of the form NEW:FUNC=OLD. Supported functions are:
|
|
370
383
|
|
|
371
|
-
| Function | Arguments
|
|
372
|
-
|
|
373
|
-
| MERGE
|
|
374
|
-
| NEG
|
|
375
|
-
| POS
|
|
376
|
-
| LOOKUP
|
|
384
|
+
| Function | Arguments | Description |
|
|
385
|
+
|------------|-------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
386
|
+
| `MERGE` | `dest=MERGE:source` | The `dest` column is written with values from one or more columns<br/>indicated by `source`. For multiple columns, which are separated<br/>by `;`, the first empty value is chosen. |
|
|
387
|
+
| `NEG` | `dest=NEG:source` | The `dest` column contains absolute values of any column that is<br/>negative. This is useful for isolating debits from account<br/>exports. |
|
|
388
|
+
| `POS` | `dest=NEG:source` | The `dest` column contains values of any column that is<br/>positive. This is useful for isolating credits from account<br/>exports. |
|
|
389
|
+
| `LOOKUP` | `dest=LOOKUP:source;filename` | A lookup map is read from `filename` which must be an Apple<br/>Numbers file containing a single table of two columns. The table<br/>is used to match against `source`, searching the first column<br/>for matches and writing the corresponding value from the second<br/>column to `dest`. Values are chosen based on the longest<br/>matching substring. |
|
|
377
390
|
|
|
378
391
|
Examples:
|
|
379
392
|
|
|
380
|
-
```
|
|
393
|
+
```bash
|
|
381
394
|
csv2numbers --transform="Paid In"=POS:Amount,Withdrawn=NEG:Amount file1.csv
|
|
382
395
|
csv2numbers --transform='Category=LOOKUP:Transaction;mapping.numbers' file1.csv
|
|
383
396
|
```
|
|
@@ -398,11 +411,20 @@ The following limitations are expected to always remain:
|
|
|
398
411
|
|
|
399
412
|
- New sheets insert tables with formats copied from the first table in the previous sheet rather than default table formats
|
|
400
413
|
- Due to a limitation in Python’s [ZipFile](https://docs.python.org/3/library/zipfile.html), Python versions older than 3.11 do not support image filenames with UTF-8 characters [Cell.add_style.bg_image()](https://masaccio.github.io/numbers-parser/api/sheet.html#numbers_parser.Style) returns `None` for such files and issues a `RuntimeWarning` (see [issue 69](https://github.com/masaccio/numbers-parser/issues/69) for details).
|
|
401
|
-
- Password-encrypted documents cannot be opened. You must first re-save without a password to read (see [issue 88](https://github.com/masaccio/numbers-parser/issues/88) for details). A UnsupportedError exception is raised when such documents are opened.
|
|
402
414
|
- Due to changes in the format of Numbers documents, decoding of category groups (introduced in `numbers-parser` version 4.16) is supported only for documents created by Numbers 12.0 and later. No warnings are issued for earlier
|
|
403
415
|
Numbers documents.
|
|
404
416
|
- Only standard macOS fonts are not supported. If a document includes a non-standard font, numbers-parser will issue a UnsupportedWarning and default styles to Helvetica Neue. Reading font names from the system would add additional system-specific dependencies to the package and so this is not planned to changed.
|
|
405
417
|
|
|
406
418
|
## License
|
|
407
419
|
|
|
408
|
-
All code in this repository is licensed under the [MIT License](https://github.com/masaccio/numbers-parser/blob/
|
|
420
|
+
All code in this repository is licensed under the [MIT License](https://github.com/masaccio/numbers-parser/blob/main/LICENSE.rst).
|
|
421
|
+
|
|
422
|
+
### Credits
|
|
423
|
+
|
|
424
|
+
`numbers-parser` was built by [Jon Connell](http://github.com/masaccio) but relies heavily on from [prior work](https://github.com/psobot/keynote-parser) by [Peter Sobot](https://petersobot.com) to read the IWA format archives used by Apple’s iWork family of applications, and to regenerate the mapping files required for Python. Both modules are derived from [previous work](https://github.com/obriensp/iWorkFileFormat/blob/master/Docs/index.md) by [Sean Patrick O’Brien](http://www.obriensp.com).
|
|
425
|
+
|
|
426
|
+
Decoding the data structures inside Numbers files was helped greatly by [Stingray-Reader](https://github.com/slott56/Stingray-Reader) by [Steven Lott](https://github.com/slott56).
|
|
427
|
+
|
|
428
|
+
Formula tests were adapted from JavaScript tests used in [fast-formula-parser](https://github.com/LesterLyu/fast-formula-parser).
|
|
429
|
+
|
|
430
|
+
Decimal128 conversion to and from byte storage was adapted from work done by the [SheetsJS project](https://github.com/SheetJS/sheetjs). SheetJS also helped greatly with some of the steps required to successfully save a Numbers spreadsheet.
|
|
@@ -10,7 +10,7 @@ It supports and is tested against Python versions from 3.10 onwards. It is not c
|
|
|
10
10
|
|
|
11
11
|
A pre-requisite for this package is [python-snappy](https://pypi.org/project/python-snappy/) which will be installed by Python automatically, but python-snappy also requires binary libraries for snappy compression.
|
|
12
12
|
|
|
13
|
-
The most straightforward way to install the binary dependencies is to use [Homebrew](https://brew.sh) and source Python from Homebrew rather than from macOS as described in the [python-snappy github](https://github.com/andrix/python-snappy). Using [pipx](https://pipx.pypa.io/stable/
|
|
13
|
+
The most straightforward way to install the binary dependencies is to use [Homebrew](https://brew.sh) and source Python from Homebrew rather than from macOS as described in the [python-snappy github](https://github.com/andrix/python-snappy). Using [pipx](https://pipx.pypa.io/stable/how-to/install-pipx.html) for package management is also strongly recommended:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
brew install snappy python3 pipx
|
|
@@ -41,8 +41,14 @@ Reading documents:
|
|
|
41
41
|
>>> rows = tables[0].rows()
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
Encrypted documents are also supported for reading:
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
>>> from numbers_parser import Document
|
|
48
|
+
>>> doc = Document("mydoc.numbers", password="s3cr3t")
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Sheets and tables are iterables that can be indexed using either an integer index or using the name of the sheet/table:
|
|
46
52
|
|
|
47
53
|
```python
|
|
48
54
|
>>> doc.sheets[0].name
|
|
@@ -50,30 +56,26 @@ integer index or using the name of the sheet/table:
|
|
|
50
56
|
>>> doc.sheets["Sheet 1"].name
|
|
51
57
|
'Sheet 1'
|
|
52
58
|
>>> doc.sheets[0].tables[0].name
|
|
53
|
-
'
|
|
54
|
-
>>> doc.sheets[0].tables["
|
|
55
|
-
'
|
|
59
|
+
'Categories'
|
|
60
|
+
>>> doc.sheets[0].tables["Categories"].name
|
|
61
|
+
'Categories'
|
|
56
62
|
```
|
|
57
63
|
|
|
58
|
-
`Table` objects have a `rows` method which contains a nested list
|
|
59
|
-
with an entry for each row of the table. Each row is itself a list of
|
|
60
|
-
the column values.
|
|
64
|
+
`Table` objects have a `rows` method which contains a nested list with an entry for each row of the table. Each row is itself a list of the column values.
|
|
61
65
|
|
|
62
66
|
```python
|
|
63
|
-
>>> data = sheets["Sheet 1"].tables["
|
|
67
|
+
>>> data = doc.sheets["Sheet 1"].tables["Examples"].rows()
|
|
64
68
|
>>> data[0][0]
|
|
65
|
-
|
|
69
|
+
numbers_parser.cell.EmptyCell(sheet_name='Sheet 1', table_name='Examples', value='None', row=0, col=0)
|
|
66
70
|
>>> data[1][0]
|
|
67
|
-
|
|
71
|
+
numbers_parser.cell.TextCell(sheet_name='Sheet 1', table_name='Examples', value='Debit', row=1, col=0)
|
|
68
72
|
>>> data[1][0].value
|
|
69
73
|
'Debit'
|
|
70
74
|
```
|
|
71
75
|
|
|
72
76
|
### Cell Data
|
|
73
77
|
|
|
74
|
-
Cells are objects with a common base class of `Cell`. All cell types
|
|
75
|
-
have a property `value` which returns the contents of the cell as a
|
|
76
|
-
python datatype. Available cell types are:
|
|
78
|
+
Cells are objects with a common base class of `Cell`. All cell types have a property `value` which returns the contents of the cell as a python datatype. Available cell types are:
|
|
77
79
|
|
|
78
80
|
| Cell type | value type | Additional properties |
|
|
79
81
|
|--------------|----------------------|--------------------------------------------------------------------------------------------------------|
|
|
@@ -91,11 +93,11 @@ Cell references can be either zero-offset row/column integers or an Excel/Number
|
|
|
91
93
|
|
|
92
94
|
```python
|
|
93
95
|
>>> table.cell(1,0)
|
|
94
|
-
|
|
96
|
+
numbers_parser.cell.TextCell(sheet_name='Sheet 1', table_name='Examples', value='Debit', row=1, col=0)
|
|
95
97
|
>>> table.cell(1,0).value
|
|
96
98
|
'Debit'
|
|
97
99
|
>>> table.cell("B2")
|
|
98
|
-
|
|
100
|
+
numbers_parser.cell.NumberCell(sheet_name='Sheet 1', table_name='Examples', value='1234.5', row=1, col=1)
|
|
99
101
|
>>> table.cell("B2").value
|
|
100
102
|
1234.5
|
|
101
103
|
>>> table.cell("B2").formatted_value
|
|
@@ -109,7 +111,7 @@ Since the return value of `rows()` is a list of lists, you can pass this directl
|
|
|
109
111
|
```python
|
|
110
112
|
import pandas as pd
|
|
111
113
|
|
|
112
|
-
doc = Document("
|
|
114
|
+
doc = Document("mydoc.numbers")
|
|
113
115
|
sheets = doc.sheets
|
|
114
116
|
tables = sheets[0].tables
|
|
115
117
|
data = tables[0].rows(values_only=True)
|
|
@@ -123,13 +125,19 @@ Whilst support for writing numbers files has been stable since version 3.4.0, yo
|
|
|
123
125
|
Cell values are written using [Table.write()](https://masaccio.github.io/numbers-parser/api/table.html#numbers_parser.Table.write) and `numbers-parser` will automatically create empty rows and columns for any cell references that are out of range of the current table.
|
|
124
126
|
|
|
125
127
|
```python
|
|
126
|
-
doc = Document("
|
|
128
|
+
doc = Document("mydoc.numbers")
|
|
127
129
|
sheets = doc.sheets
|
|
128
130
|
tables = sheets[0].tables
|
|
129
131
|
table = tables[0]
|
|
130
132
|
table.write(1, 1, "This is new text")
|
|
131
133
|
table.write("B7", datetime(2020, 12, 25))
|
|
132
|
-
doc.save("
|
|
134
|
+
doc.save("mydoc.numbers")
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Encrypted documents are not automatically re-saved with encryption and you must specify a password on save:
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
doc.save("mydoc.numbers", password="s3cr3t")
|
|
133
141
|
```
|
|
134
142
|
|
|
135
143
|
Additional tables and worksheets can be added to a `Document` before saving using [Document.add_sheet()](https://masaccio.github.io/numbers-parser/api/document.html#numbers_parser.Document.add_sheet) and [Sheet.add_table()](https://masaccio.github.io/numbers-parser/api/sheet.html#numbers_parser.Sheet.add_table) respectively:
|
|
@@ -142,7 +150,7 @@ table = sheet.tables["New Table"]
|
|
|
142
150
|
table.write(1, 1, 1000)
|
|
143
151
|
table.write(1, 2, 2000)
|
|
144
152
|
table.write(1, 3, 3000)
|
|
145
|
-
doc.save("
|
|
153
|
+
doc.save("mydoc.numbers")
|
|
146
154
|
```
|
|
147
155
|
|
|
148
156
|
### Styles
|
|
@@ -193,8 +201,8 @@ table.set_cell_formatting(
|
|
|
193
201
|
date_time_format="EEEE, d MMMM yyyy"
|
|
194
202
|
)
|
|
195
203
|
table.set_cell_formatting(
|
|
196
|
-
|
|
197
|
-
|
|
204
|
+
1,
|
|
205
|
+
1,
|
|
198
206
|
"number",
|
|
199
207
|
decimal_places=3,
|
|
200
208
|
negative_style=NegativeNumberStyle.RED
|
|
@@ -207,7 +215,7 @@ Custom formats are shared across a Document and can be applied to multiple cells
|
|
|
207
215
|
long_date = doc.add_custom_format(
|
|
208
216
|
name="Long Date",
|
|
209
217
|
type="datetime",
|
|
210
|
-
|
|
218
|
+
format="EEEE, d MMMM yyyy"
|
|
211
219
|
)
|
|
212
220
|
table.set_cell_formatting("C1", "custom", format=long_date)
|
|
213
221
|
```
|
|
@@ -261,6 +269,7 @@ options:
|
|
|
261
269
|
Names of sheet(s) to include in export
|
|
262
270
|
-t TABLE, --table TABLE
|
|
263
271
|
Names of table(s) to include in export
|
|
272
|
+
--password PASSWORD Password for encrypted documents
|
|
264
273
|
--debug Enable debug logging
|
|
265
274
|
```
|
|
266
275
|
|
|
@@ -270,7 +279,7 @@ Note: `--formatting` will return different capitalization for 12-hour times due
|
|
|
270
279
|
|
|
271
280
|
This script converts Excel-compatible CSV files into Numbers documents. Output files can optionally be provided, but is none are provided, the output is created by replacing the input’s files suffix with .numbers. For example:
|
|
272
281
|
|
|
273
|
-
```
|
|
282
|
+
```bash
|
|
274
283
|
csv2numbers file1.csv file2.csv -o file1.numbers file2.numbers
|
|
275
284
|
```
|
|
276
285
|
|
|
@@ -297,6 +306,7 @@ options:
|
|
|
297
306
|
--no-header CSV file has no header row (default: false)
|
|
298
307
|
--day-first dates are represented day first in the CSV file
|
|
299
308
|
(default: false)
|
|
309
|
+
--encoding ENCODING python-style text encoding of the CSV file (default: utf-8)
|
|
300
310
|
--date COLUMNS comma-separated list of column names/indexes to
|
|
301
311
|
parse as dates
|
|
302
312
|
--rename COLUMNS-MAP comma-separated list of column names/indexes to
|
|
@@ -309,6 +319,7 @@ options:
|
|
|
309
319
|
-o [FILENAME ...], --output [FILENAME ...]
|
|
310
320
|
output filename (default: use source file with
|
|
311
321
|
.numbers)
|
|
322
|
+
--password PASSWORD Password for encrypted documents
|
|
312
323
|
```
|
|
313
324
|
|
|
314
325
|
The following options affecting the output of the entire file. The default for each is always false.
|
|
@@ -324,7 +335,7 @@ The following options affecting the output of the entire file. The default for e
|
|
|
324
335
|
|
|
325
336
|
Delete columns using `--delete`. The names or indices of the columns to delete are specified as comma-separated values:
|
|
326
337
|
|
|
327
|
-
```
|
|
338
|
+
```bash
|
|
328
339
|
csv2numbers file1.csv --delete=Account,3
|
|
329
340
|
```
|
|
330
341
|
|
|
@@ -332,28 +343,28 @@ csv2numbers file1.csv --delete=Account,3
|
|
|
332
343
|
|
|
333
344
|
Rename columns using `--rename`. The current column name and new column name are separated by a `:` and each renaming is specified as comma-separated values:
|
|
334
345
|
|
|
335
|
-
```
|
|
346
|
+
```bash
|
|
336
347
|
csv2numbers file1.csv --rename=2:Account,"Paid In":Amount
|
|
337
348
|
```
|
|
338
349
|
|
|
339
350
|
#### Date columns
|
|
340
351
|
|
|
341
|
-
The `--date` option identifies a comma-separated list of columns that should be parsed as dates. Use `--day-first` where the day and month is ambiguous
|
|
352
|
+
The `--date` option identifies a comma-separated list of columns that should be parsed as dates. Use `--day-first` where the day and month is ambiguous and the day comes first rather than the month.
|
|
342
353
|
|
|
343
354
|
#### Transforming columns
|
|
344
355
|
|
|
345
|
-
Columns can be merged and new columns created using simple functions. The –transform option takes a comma-
|
|
356
|
+
Columns can be merged and new columns created using simple functions. The –transform option takes a comma-separated list of transformations of the form NEW:FUNC=OLD. Supported functions are:
|
|
346
357
|
|
|
347
|
-
| Function | Arguments
|
|
348
|
-
|
|
349
|
-
| MERGE
|
|
350
|
-
| NEG
|
|
351
|
-
| POS
|
|
352
|
-
| LOOKUP
|
|
358
|
+
| Function | Arguments | Description |
|
|
359
|
+
|------------|-------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
360
|
+
| `MERGE` | `dest=MERGE:source` | The `dest` column is written with values from one or more columns<br/>indicated by `source`. For multiple columns, which are separated<br/>by `;`, the first empty value is chosen. |
|
|
361
|
+
| `NEG` | `dest=NEG:source` | The `dest` column contains absolute values of any column that is<br/>negative. This is useful for isolating debits from account<br/>exports. |
|
|
362
|
+
| `POS` | `dest=NEG:source` | The `dest` column contains values of any column that is<br/>positive. This is useful for isolating credits from account<br/>exports. |
|
|
363
|
+
| `LOOKUP` | `dest=LOOKUP:source;filename` | A lookup map is read from `filename` which must be an Apple<br/>Numbers file containing a single table of two columns. The table<br/>is used to match against `source`, searching the first column<br/>for matches and writing the corresponding value from the second<br/>column to `dest`. Values are chosen based on the longest<br/>matching substring. |
|
|
353
364
|
|
|
354
365
|
Examples:
|
|
355
366
|
|
|
356
|
-
```
|
|
367
|
+
```bash
|
|
357
368
|
csv2numbers --transform="Paid In"=POS:Amount,Withdrawn=NEG:Amount file1.csv
|
|
358
369
|
csv2numbers --transform='Category=LOOKUP:Transaction;mapping.numbers' file1.csv
|
|
359
370
|
```
|
|
@@ -374,11 +385,20 @@ The following limitations are expected to always remain:
|
|
|
374
385
|
|
|
375
386
|
- New sheets insert tables with formats copied from the first table in the previous sheet rather than default table formats
|
|
376
387
|
- Due to a limitation in Python’s [ZipFile](https://docs.python.org/3/library/zipfile.html), Python versions older than 3.11 do not support image filenames with UTF-8 characters [Cell.add_style.bg_image()](https://masaccio.github.io/numbers-parser/api/sheet.html#numbers_parser.Style) returns `None` for such files and issues a `RuntimeWarning` (see [issue 69](https://github.com/masaccio/numbers-parser/issues/69) for details).
|
|
377
|
-
- Password-encrypted documents cannot be opened. You must first re-save without a password to read (see [issue 88](https://github.com/masaccio/numbers-parser/issues/88) for details). A UnsupportedError exception is raised when such documents are opened.
|
|
378
388
|
- Due to changes in the format of Numbers documents, decoding of category groups (introduced in `numbers-parser` version 4.16) is supported only for documents created by Numbers 12.0 and later. No warnings are issued for earlier
|
|
379
389
|
Numbers documents.
|
|
380
390
|
- Only standard macOS fonts are not supported. If a document includes a non-standard font, numbers-parser will issue a UnsupportedWarning and default styles to Helvetica Neue. Reading font names from the system would add additional system-specific dependencies to the package and so this is not planned to changed.
|
|
381
391
|
|
|
382
392
|
## License
|
|
383
393
|
|
|
384
|
-
All code in this repository is licensed under the [MIT License](https://github.com/masaccio/numbers-parser/blob/
|
|
394
|
+
All code in this repository is licensed under the [MIT License](https://github.com/masaccio/numbers-parser/blob/main/LICENSE.rst).
|
|
395
|
+
|
|
396
|
+
### Credits
|
|
397
|
+
|
|
398
|
+
`numbers-parser` was built by [Jon Connell](http://github.com/masaccio) but relies heavily on from [prior work](https://github.com/psobot/keynote-parser) by [Peter Sobot](https://petersobot.com) to read the IWA format archives used by Apple’s iWork family of applications, and to regenerate the mapping files required for Python. Both modules are derived from [previous work](https://github.com/obriensp/iWorkFileFormat/blob/master/Docs/index.md) by [Sean Patrick O’Brien](http://www.obriensp.com).
|
|
399
|
+
|
|
400
|
+
Decoding the data structures inside Numbers files was helped greatly by [Stingray-Reader](https://github.com/slott56/Stingray-Reader) by [Steven Lott](https://github.com/slott56).
|
|
401
|
+
|
|
402
|
+
Formula tests were adapted from JavaScript tests used in [fast-formula-parser](https://github.com/LesterLyu/fast-formula-parser).
|
|
403
|
+
|
|
404
|
+
Decimal128 conversion to and from byte storage was adapted from work done by the [SheetsJS project](https://github.com/SheetJS/sheetjs). SheetJS also helped greatly with some of the steps required to successfully save a Numbers spreadsheet.
|