Codebase list pyexcel-ods / 3fc0533
:handshake: merge with master branch chfw 5 years ago
26 changed file(s) with 564 addition(s) and 226 deletion(s). Raw diff Collapse all Expand all
44
55 {%block compat_block%}
66 {%endblock%}
7
00 {% extends 'tests/requirements.txt.jj2' %}
11 {%block extras %}
2 moban
3 black;python_version>="3.6"
4 isort;python_version>="3.6"
25 psutil
36 pyexcel
47 pyexcel-xls
00 {% extends 'tests/test_formatters.py.jj2' %}
11
22 {% block test_date_format %}
3 {% endblock %}
3 {% endblock %}
0 requires:
1 - type: git
2 url: https://github.com/moremoban/pypi-mobans
3 submodule: true
4 - https://github.com/pyexcel/pyexcel-mobans
05 configuration:
1 configuration_dir: "commons/config"
6 configuration_dir: "pyexcel-mobans:config"
27 template_dir:
3 - "commons/templates"
4 - "setupmobans/templates"
8 - "pyexcel-mobans:templates"
9 - "pypi-mobans:templates"
510 - ".moban.d"
611 configuration: pyexcel-ods.yml
712 targets:
2126 - "tests/test_stringio.py": "tests/test_stringio.py.jj2"
2227 - "tests/test_writer.py": "tests/test_writer.py.jj2"
2328 - "tests/base.py": "tests/base.py.jj2"
29 - output: CHANGELOG.rst
30 configuration: changelog.yml
31 template: CHANGELOG.rst.jj2
00 Change log
11 ================================================================================
22
3 0.5.4 - 27.11.2018
4 --------------------------------------------------------------------------------
5
6 added
7 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8
9 #. `#30 <https://github.com/pyexcel/pyexcel-ods/issues/30>`_, long type will not
10 be written in ods. please use string type. And if the integer is equal or
11 greater than 10 to the power of 16, it will not be written either in ods. In
12 both situation, IntegerPrecisionLossError will be raised.
13
14 0.5.3 - unreleased
15 --------------------------------------------------------------------------------
16
17 added
18 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19
20 #. `#24 <https://github.com/pyexcel/pyexcel-ods/issues/24>`_, ignore
21 comments(<office:comment>) in cell
22 #. `#27 <https://github.com/pyexcel/pyexcel-ods/issues/27>`_, exception raised
23 when currency type is missing
24 #. fix odfpy version on 1.3.5.
25
26 0.5.2 - 23.10.2017
27 --------------------------------------------------------------------------------
28
29 updated
30 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
31
32 #. pyexcel `pyexcel#105 <https://github.com/pyexcel/pyexcel/issues/105>`_,
33 remove gease from setup_requires, introduced by 0.5.1.
34 #. remove python2.6 test support
35
36 0.5.1 - 20.10.2017
37 --------------------------------------------------------------------------------
38
39 added
40 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
41
42 #. `pyexcel#103 <https://github.com/pyexcel/pyexcel/issues/103>`_, include
43 LICENSE file in MANIFEST.in, meaning LICENSE file will appear in the released
44 tar ball.
45
46 0.5.0 - 30.08.2017
47 --------------------------------------------------------------------------------
48
49 Updated
50 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
51
52 #. put dependency on pyexcel-io 0.5.0, which uses cStringIO instead of StringIO.
53 Hence, there will be performance boost in handling files in memory.
54
55 Relocated
56 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
57
58 #. All ods type conversion code lives in pyexcel_io.service module
59
360 0.4.1 - 25.08.2017
461 --------------------------------------------------------------------------------
562
663 Updated
7 ********************************************************************************
8
9 #. `#23 <https://github.com/pyexcel/pyexcel-ods/issues/23>`_, handle unseekable
10 stream given by http response
64 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
65
66 #. `pyexcel#23 <https://github.com/pyexcel/pyexcel/issues/23>`_, handle
67 unseekable stream given by http response
1168 #. PR `#22 <https://github.com/pyexcel/pyexcel-ods/pull/22>`_, hanle white
1269 spaces in a cell.
1370
1572 --------------------------------------------------------------------------------
1673
1774 Updated
18 ********************************************************************************
19
20 #. `#14 <https://github.com/pyexcel/pyexcel-xlsx/issues/14>`_, close file
75 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
76
77 #. `pyexcel#14 <https://github.com/pyexcel/pyexcel/issues/14>`_, close file
2178 handle
22 #. pyexcel-io plugin interface now updated to use
23 `lml <https://github.com/chfw/lml>`_.
24
79 #. pyexcel-io plugin interface now updated to use `lml
80 <https://github.com/chfw/lml>`_.
2581
2682 0.3.3 - 07.05.2017
2783 --------------------------------------------------------------------------------
2884
2985 Updated
30 ********************************************************************************
31
32 #. issue `#19 <https://github.com/pyexcel/pyexcel-odsr/issues/19>`_, not all texts
33 in a multi-node cell were extracted.
86 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
87
88 #. issue `pyexcel#19 <https://github.com/pyexcel/pyexcel/issues/19>`_, not all
89 texts in a multi-node cell were extracted.
3490
3591 0.3.2 - 13.04.2017
3692 --------------------------------------------------------------------------------
3793
3894 Updated
39 ********************************************************************************
40
41 #. issue `#17 <https://github.com/pyexcel/pyexcel-ods/issues/17>`_, empty
42 new line is ignored
43 #. issue `#6 <https://github.com/pyexcel/pyexcel-ods/issues/6>`_, PT288H00M00S
44 is valid duration
95 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
96
97 #. issue `pyexcel#17 <https://github.com/pyexcel/pyexcel/issues/17>`_, empty new
98 line is ignored
99 #. issue `pyexcel#6 <https://github.com/pyexcel/pyexcel/issues/6>`_,
100 PT288H00M00S is valid duration
45101
46102 0.3.1 - 02.02.2017
47103 --------------------------------------------------------------------------------
48104
49105 Added
50 ********************************************************************************
106 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
51107
52108 #. Recognize currency type
53109
55111 --------------------------------------------------------------------------------
56112
57113 Updated
58 ********************************************************************************
114 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
59115
60116 #. Code refactoring with pyexcel-io v 0.3.0
61117
62
63118 0.2.2 - 24.10.2016
64119 --------------------------------------------------------------------------------
65120
66121 Updated
67 ********************************************************************************
68
69 #. issue `#14 <https://github.com/pyexcel/pyexcel-ods/issues/14>`_, index error
70 when reading a ods file that has non-uniform columns repeated property.
71
122 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
123
124 #. issue `pyexcel#14 <https://github.com/pyexcel/pyexcel/issues/14>`_, index
125 error when reading a ods file that has non-uniform columns repeated property.
72126
73127 0.2.1 - 31.08.2016
74128 --------------------------------------------------------------------------------
75129
76130 Added
77 ********************************************************************************
131 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
78132
79133 #. support pagination. two pairs: start_row, row_limit and start_column,
80134 column_limit help you deal with large files.
84138 --------------------------------------------------------------------------------
85139
86140 Added
87 ********************************************************************************
141 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
88142
89143 #. By default, `float` will be converted to `int` where fits. `auto_detect_int`,
90144 a flag to switch off the autoatic conversion from `float` to `int`.
91145 #. 'library=pyexcel-ods' was added so as to inform pyexcel to use it instead of
92146 other libraries, in the situation where multiple plugins were installed.
93147
94
95 Updated
96 ********************************************************************************
148 Updated
149 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
97150
98151 #. support the auto-import feature of pyexcel-io 0.2.0
99152
100
101153 0.1.1 - 30.01.2016
102154 --------------------------------------------------------------------------------
103155
104156 Added
105 ********************************************************************************
106
107 #. 'streaming' is an extra option given to get_data. Only when 'streaming'
108 is explicitly set to True, the data will be consisted of generators,
109 hence will break your existing code.
157 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
158
159 #. 'streaming' is an extra option given to get_data. Only when 'streaming' is
160 explicitly set to True, the data will be consisted of generators, hence will
161 break your existing code.
110162 #. uses yield in to_array and returns a generator
111163 #. support multi-line text cell #5
112164 #. feature migration from pyexcel-ods3 pyexcel/pyexcel-ods3#5
113165
114166 Updated
115 ********************************************************************************
167 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
168
116169 #. compatibility with pyexcel-io 0.1.1
117170
118
119171 0.0.12 - 10.10.2015
120172 --------------------------------------------------------------------------------
121173
122174 Updated
123 ********************************************************************************
175 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
176
124177 #. Bug fix: excessive trailing columns with empty values
125178
126
127179 0.0.11 - 26.09.2015
128180 --------------------------------------------------------------------------------
129181
130182 Updated
131 ********************************************************************************
183 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
184
132185 #. Complete fix for libreoffice datetime field
133186
134
135187 0.0.10 - 15.09.2015
136188 --------------------------------------------------------------------------------
137189
138190 Updated
139 ********************************************************************************
191 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
192
140193 #. Bug fix: date field could have datetime from libreoffice
141194
142
143195 0.0.9 - 21.08.2015
144196 --------------------------------------------------------------------------------
145197
146198 Updated
147 ********************************************************************************
199 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
200
148201 #. Bug fix: utf-8 string throw unicode exceptions
149202
150
151203 0.0.8 - 28.06.2015
152204 --------------------------------------------------------------------------------
153205
154206 Updated
155 ********************************************************************************
207 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
208
156209 #. Pin dependency odfpy 0.9.6 to avoid buggy odfpy 1.3.0
157210
158
159211 0.0.7 - 28.05.2015
160212 --------------------------------------------------------------------------------
161213
162214 Updated
163 ********************************************************************************
215 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
216
164217 #. Bug fix: "number-columns-repeated" is now respected
165218
166
167219 0.0.6 - 21.05.2015
168220 --------------------------------------------------------------------------------
169221
170222 Updated
171 ********************************************************************************
223 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
224
172225 #. get_data and save_data are seen across pyexcel-* extensions. remember them
173226 once and use them across all extensions.
174227
175
176228 0.0.5 - 22.02.2015
177229 --------------------------------------------------------------------------------
178230
179231 Added
180 ********************************************************************************
232 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
181233
182234 #. Loads only one sheet from a multiple sheet book
183235 #. Use New BSD License
184236
185
186237 0.0.4 - 14.12.2014
187238 --------------------------------------------------------------------------------
188239
189240 Updated
190 ********************************************************************************
241 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
242
191243 #. IO interface update as pyexcel-io introduced keywords.
192
244 #. initial release
193245
194246 0.0.3 - 08.12.2014
195247 --------------------------------------------------------------------------------
196248
249 Updated
250 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
251
252 #. IO interface update as pyexcel-io introduced keywords.
197253 #. initial release
22 test:
33 bash test.sh
44
5 format:
6 isort -y $(find pyexcel_ods -name "*.py"|xargs echo) $(find tests -name "*.py"|xargs echo)
7 black -l 79 pyexcel_ods
8 black -l 79 tests
0 name: pyexcel-ods
1 organisation: pyexcel
2 releases:
3 - changes:
4 - action: added
5 details:
6 - '`#32`, fix odfpy pinning'
7 date: 16.03.2019
8 version: 0.5.5
9 - changes:
10 - action: added
11 details:
12 - '`#30`, long type will not be written in ods. please use string type. And if the integer is equal or greater than 10 to the power of 16, it will not be written either in ods. In both situation, IntegerPrecisionLossError will be raised.'
13 date: 27.11.2018
14 version: 0.5.4
15 - changes:
16 - action: added
17 details:
18 - '`#24`, ignore comments(<office:comment>) in cell'
19 - '`#27`, exception raised when currency type is missing'
20 - fix odfpy version on 1.3.5.
21 date: unreleased
22 version: 0.5.3
23 - changes:
24 - action: updated
25 details:
26 - pyexcel `pyexcel#105`, remove gease from setup_requires, introduced by 0.5.1.
27 - remove python2.6 test support
28 date: 23.10.2017
29 version: 0.5.2
30 - changes:
31 - action: added
32 details:
33 - '`pyexcel#103`, include LICENSE file in MANIFEST.in, meaning LICENSE file will
34 appear in the released tar ball.'
35 date: 20.10.2017
36 version: 0.5.1
37 - changes:
38 - action: Updated
39 details:
40 - put dependency on pyexcel-io 0.5.0, which uses cStringIO instead of StringIO. Hence,
41 there will be performance boost in handling files in memory.
42 - action: Relocated
43 details:
44 - All ods type conversion code lives in pyexcel_io.service module
45 date: 30.08.2017
46 version: 0.5.0
47 - changes:
48 - action: Updated
49 details:
50 - '`pyexcel#pyexcel-ods#23`, handle unseekable stream given by http response'
51 - PR `pyexcel#pyexcel-ods#PR#22`, hanle white spaces in a cell.
52 date: 25.08.2017
53 version: 0.4.1
54 - changes:
55 - action: Updated
56 details:
57 - '`pyexcel#pyexcel-xlsx#14`, close file handle'
58 - pyexcel-io plugin interface now updated to use `lml <https://github.com/chfw/lml>`_.
59 date: 19.06.2017
60 version: 0.4.0
61 - changes:
62 - action: Updated
63 details:
64 - issue `pyexcel#pyexcel-odsr#19`, not all texts in a multi-node cell were extracted.
65 date: 07.05.2017
66 version: 0.3.3
67 - changes:
68 - action: Updated
69 details:
70 - issue `pyexcel#pyexcel-ods#17`, empty new line is ignored
71 - issue `pyexcel#pyexcel-ods#6`, PT288H00M00S is valid duration
72 date: 13.04.2017
73 version: 0.3.2
74 - changes:
75 - action: Added
76 details:
77 - Recognize currency type
78 date: 02.02.2017
79 version: 0.3.1
80 - changes:
81 - action: Updated
82 details:
83 - Code refactoring with pyexcel-io v 0.3.0
84 date: 22.12.2016
85 version: 0.3.0
86 - changes:
87 - action: Updated
88 details:
89 - issue `pyexcel#pyexcel-ods#14`, index error when reading a ods file that has
90 non-uniform columns repeated property.
91 date: 24.10.2016
92 version: 0.2.2
93 - changes:
94 - action: Added
95 details:
96 - 'support pagination. two pairs: start_row, row_limit and start_column, column_limit
97 help you deal with large files.'
98 - use odfpy 1.3.3 as compulsory package. offically support python 3
99 date: 31.08.2016
100 version: 0.2.1
101 - changes:
102 - action: Added
103 details:
104 - By default, `float` will be converted to `int` where fits. `auto_detect_int`, a
105 flag to switch off the autoatic conversion from `float` to `int`.
106 - '''library=pyexcel-ods'' was added so as to inform pyexcel to use it instead
107 of other libraries, in the situation where multiple plugins were installed.'
108 - action: Updated
109 details:
110 - support the auto-import feature of pyexcel-io 0.2.0
111 date: 01.06.2016
112 version: 0.2.0
113 - changes:
114 - action: Added
115 details:
116 - '''streaming'' is an extra option given to get_data. Only when ''streaming'' is
117 explicitly set to True, the data will be consisted of generators, hence will
118 break your existing code.'
119 - uses yield in to_array and returns a generator
120 - 'support multi-line text cell #5'
121 - feature migration from pyexcel-ods3 pyexcel/pyexcel-ods3#5
122 - action: Updated
123 details:
124 - compatibility with pyexcel-io 0.1.1
125 date: 30.01.2016
126 version: 0.1.1
127 - changes:
128 - action: Updated
129 details:
130 - 'Bug fix: excessive trailing columns with empty values'
131 date: 10.10.2015
132 version: 0.0.12
133 - changes:
134 - action: Updated
135 details:
136 - Complete fix for libreoffice datetime field
137 date: 26.09.2015
138 version: 0.0.11
139 - changes:
140 - action: Updated
141 details:
142 - 'Bug fix: date field could have datetime from libreoffice'
143 date: 15.09.2015
144 version: 0.0.10
145 - changes:
146 - action: Updated
147 details:
148 - 'Bug fix: utf-8 string throw unicode exceptions'
149 date: 21.08.2015
150 version: 0.0.9
151 - changes:
152 - action: Updated
153 details:
154 - Pin dependency odfpy 0.9.6 to avoid buggy odfpy 1.3.0
155 date: 28.06.2015
156 version: 0.0.8
157 - changes:
158 - action: Updated
159 details:
160 - 'Bug fix: "number-columns-repeated" is now respected'
161 date: 28.05.2015
162 version: 0.0.7
163 - changes:
164 - action: Updated
165 details:
166 - get_data and save_data are seen across pyexcel-* extensions. remember them once
167 and use them across all extensions.
168 date: 21.05.2015
169 version: 0.0.6
170 - changes:
171 - action: Added
172 details:
173 - Loads only one sheet from a multiple sheet book
174 - Use New BSD License
175 date: 22.02.2015
176 version: 0.0.5
177 - changes:
178 - action: Updated
179 details:
180 - IO interface update as pyexcel-io introduced keywords.
181 - initial release
182 date: 14.12.2014
183 version: 0.0.4
184 - changes:
185 - action: Updated
186 details:
187 - IO interface update as pyexcel-io introduced keywords.
188 - initial release
189 date: 08.12.2014
190 version: 0.0.3
2424 copyright = 'copyright 2015-2019 Onni Software Ltd.'
2525 author = 'Onni Software Ltd.'
2626 # The short X.Y version
27 version = '0.4.2'
27 version = '0.5.5'
2828 # The full version, including alpha/beta/rc tags
29 release = '0.4.1'
29 release = '0.5.4'
3030
3131 # -- General configuration ---------------------------------------------------
3232
00 overrides: "pyexcel.yaml"
11 name: "pyexcel-ods"
22 nick_name: ods
3 version: 0.4.2
4 current_version: 0.4.2
5 release: 0.4.1
3 version: 0.5.5
4 current_version: 0.5.5
5 release: 0.5.4
66 file_type: ods
77 dependencies:
8 - pyexcel-io>=0.4.0
9 - odfpy>=1.3.3
8 - pyexcel-io>=0.5.10
9 - odfpy==1.3.5
1010 description: A wrapper library to read, manipulate and write data in ods format
88 # this line has to be place above all else
99 # because of dynamic import
1010 from pyexcel_io.plugins import IOPluginInfoChain
11 from pyexcel_io.io import get_data as read_data, isstream, store_data as write_data
11 from pyexcel_io.io import (
12 get_data as read_data,
13 isstream,
14 store_data as write_data,
15 )
1216
13 __FILE_TYPE__ = 'ods'
17 __FILE_TYPE__ = "ods"
1418 IOPluginInfoChain(__name__).add_a_reader(
15 relative_plugin_class_path='odsr.ODSBook',
19 relative_plugin_class_path="odsr.ODSBook",
1620 file_types=[__FILE_TYPE__],
17 stream_type='binary'
21 stream_type="binary",
1822 ).add_a_writer(
19 relative_plugin_class_path='odsw.ODSWriter',
23 relative_plugin_class_path="odsw.ODSWriter",
2024 file_types=[__FILE_TYPE__],
21 stream_type='binary'
25 stream_type="binary",
2226 )
2327
2428
2020 # See the License for the specific language governing permissions and
2121 # limitations under the License.
2222
23 import pyexcel_io.service as service
24 from odf.namespaces import OFFICENS
25 from odf.opendocument import load
26 from odf.table import Table, TableCell, TableRow
27
2328 # Thanks to grt for the fixes
2429 from odf.teletype import extractText
25 from odf.table import TableRow, TableCell, Table
2630 from odf.text import P
27 from odf.namespaces import OFFICENS
28 from odf.opendocument import load
29
31 from pyexcel_io._compact import OrderedDict
3032 from pyexcel_io.book import BookReader
3133 from pyexcel_io.sheet import SheetReader
32 from pyexcel_io._compact import OrderedDict
33 import pyexcel_io.service as service
3434
3535
3636 class ODSSheet(SheetReader):
3737 """native ods sheet"""
38
3839 def __init__(self, sheet, auto_detect_int=True, **keywords):
3940 SheetReader.__init__(self, sheet, **keywords)
4041 self.__auto_detect_int = auto_detect_int
6869 elif cell_type == "currency":
6970 value = cell.getAttrNS(OFFICENS, value_token)
7071 currency = cell.getAttrNS(OFFICENS, cell_type)
71 ret = value + ' ' + currency
72 if currency:
73 ret = value + " " + currency
74 else:
75 ret = value
7276 else:
7377 if cell_type in service.VALUE_CONVERTERS:
7478 value = cell.getAttrNS(OFFICENS, value_token)
7579 n_value = service.VALUE_CONVERTERS[cell_type](value)
76 if cell_type == 'float' and self.__auto_detect_int:
80 if cell_type == "float" and self.__auto_detect_int:
7781 if service.has_no_digits_in_float(n_value):
7882 n_value = int(n_value)
7983 ret = n_value
8791 paragraphs = cell.getElementsByType(P)
8892 # for each text node
8993 for paragraph in paragraphs:
90 data = extractText(paragraph)
91 text_content.append(data)
92 return '\n'.join(text_content)
94 name_space, tag = paragraph.parentNode.qname
95 if tag != str("annotation"):
96 data = extractText(paragraph)
97 text_content.append(data)
98 return "\n".join(text_content)
9399
94100
95101 class ODSBook(BookReader):
96102 """read ods book"""
103
97104 def open(self, file_name, **keywords):
98105 """open ods file"""
99106 BookReader.open(self, file_name, **keywords)
107114 def read_sheet_by_name(self, sheet_name):
108115 """read a named sheet"""
109116 tables = self._native_book.spreadsheet.getElementsByType(Table)
110 rets = [table for table in tables
111 if table.getAttribute('name') == sheet_name]
117 rets = [
118 table
119 for table in tables
120 if table.getAttribute("name") == sheet_name
121 ]
112122 if len(rets) == 0:
113123 raise ValueError("%s cannot be found" % sheet_name)
114124 else:
121131 if sheet_index < length:
122132 return self.read_sheet(tables[sheet_index])
123133 else:
124 raise IndexError("Index %d of out bound %d" % (
125 sheet_index, length))
134 raise IndexError(
135 "Index %d of out bound %d" % (sheet_index, length)
136 )
126137
127138 def read_all(self):
128139 """read all sheets"""
88 """
99 import sys
1010
11 from odf.table import TableRow, TableCell, Table
12 from odf.text import P
11 import pyexcel_io.service as converter
1312 from odf.namespaces import OFFICENS
1413 from odf.opendocument import OpenDocumentSpreadsheet
15
14 from odf.table import Table, TableCell, TableRow
15 from odf.text import P
1616 from pyexcel_io.book import BookWriter
1717 from pyexcel_io.sheet import SheetWriter
18
19 import pyexcel_io.service as converter
2018
2119 PY2 = sys.version_info[0] == 2
2220
2725 """
2826 ODS sheet writer
2927 """
28
3029 def set_sheet_name(self, name):
3130 """initialize the native table"""
3231 self._native_sheet = Table(name=name)
4039 cell_to_be_written = TableCell()
4140 cell_type = type(cell)
4241 cell_odf_type = converter.ODS_WRITE_FORMAT_COVERSION.get(
43 cell_type, "string")
42 cell_type, "string"
43 )
4444 cell_to_be_written.setAttrNS(OFFICENS, "value-type", cell_odf_type)
4545 cell_odf_value_token = converter.VALUE_TOKEN.get(
46 cell_odf_type, "value")
46 cell_odf_type, "value"
47 )
4748 converter_func = converter.ODS_VALUE_CONVERTERS.get(
48 cell_odf_type, None)
49 cell_odf_type, None
50 )
4951 if converter_func:
5052 cell = converter_func(cell)
51 if cell_odf_type != 'string':
53 if cell_odf_type != "string":
5254 cell_to_be_written.setAttrNS(OFFICENS, cell_odf_value_token, cell)
5355 cell_to_be_written.addElement(P(text=cell))
5456 else:
55 lines = cell.split('\n')
57 lines = cell.split("\n")
5658 for line in lines:
5759 cell_to_be_written.addElement(P(text=line))
5860 row.addElement(cell_to_be_written)
7981 open document spreadsheet writer
8082
8183 """
84
8285 def __init__(self):
8386 BookWriter.__init__(self)
8487 self._native_book = OpenDocumentSpreadsheet()
0 pyexcel-io>=0.4.0
1 odfpy>=1.3.3
0 pyexcel-io>=0.5.10
1 odfpy==1.3.5
00 #!/usr/bin/env python3
11
2 import codecs
3 import locale
24 # Template by pypi-mobans
35 import os
6 import platform
47 import sys
5 import codecs
6 import locale
7 import platform
88 from shutil import rmtree
99
10 from setuptools import Command, setup, find_packages
11
10 from setuptools import Command, find_packages, setup
1211
1312 # Work around mbcs bug in distutils.
1413 # http://bugs.python.org/issue10945
2524
2625 NAME = 'pyexcel-ods'
2726 AUTHOR = 'C.W.'
28 VERSION = '0.4.2'
27 VERSION = '0.5.5'
2928 EMAIL = '[email protected]'
3029 LICENSE = 'New BSD'
3130 DESCRIPTION = (
3231 'A wrapper library to read, manipulate and write data in ods format'
3332 )
3433 URL = 'https://github.com/pyexcel/pyexcel-ods'
35 DOWNLOAD_URL = '%s/archive/0.4.1.tar.gz' % URL
34 DOWNLOAD_URL = '%s/archive/0.5.4.tar.gz' % URL
3635 FILES = ['README.rst', 'CHANGELOG.rst']
3736 KEYWORDS = [
3837 'python',
5150 ]
5251
5352 INSTALL_REQUIRES = [
54 'pyexcel-io>=0.4.0',
55 'odfpy>=1.3.3',
53 'pyexcel-io>=0.5.10',
54 'odfpy==1.3.5',
5655 ]
5756 SETUP_COMMANDS = {}
5857
6362 # You do not need to read beyond this line
6463 PUBLISH_COMMAND = '{0} setup.py sdist bdist_wheel upload -r pypi'.format(
6564 sys.executable)
66 GS_COMMAND = ('gs pyexcel-ods v0.4.1 ' +
67 "Find 0.4.1 in changelog for more details")
65 GS_COMMAND = ('gs pyexcel-ods v0.5.4 ' +
66 "Find 0.5.4 in changelog for more details")
6867 NO_GS_MESSAGE = ('Automatic github release is disabled. ' +
6968 'Please install gease to enable it.')
7069 UPLOAD_FAILED_MSG = (
0 import datetime # noqa
01 import os # noqa
2
3 from nose.tools import eq_, raises # noqa
4
15 import pyexcel
2 import datetime # noqa
3 from nose.tools import raises, eq_ # noqa
46
57
68 def create_sample_file1(file):
7 data = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1.1, 1]
9 data = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", 1.1, 1]
810 table = []
911 table.append(data[:4])
1012 table.append(data[4:8])
1618 """
1719 Abstract functional test for hat writers
1820 """
21
1922 content = {
2023 "X": [1, 2, 3, 4, 5],
2124 "Y": [6, 7, 8, 9, 10],
22 "Z": [11, 12, 13, 14, 15]
25 "Z": [11, 12, 13, 14, 15],
2326 }
2427
2528 def test_series_table(self):
3538 testfile and testfile2 have to be initialized before
3639 it is used for testing
3740 """
41
3842 content = [
3943 [1, 2, 3, 4, 5],
4044 [1, 2, 3, 4, 5],
4145 [1, 2, 3, 4, 5],
42 [1, 2, 3, 4, 5]
46 [1, 2, 3, 4, 5],
4347 ]
4448
4549 def _create_a_file(self, file):
5357
5458
5559 class PyexcelMultipleSheetBase:
56
5760 def _write_test_file(self, filename):
5861 pyexcel.save_book_as(bookdict=self.content, dest_file_name=filename)
5962
7982 expected = [[4, 4, 4, 4], [5, 5, 5, 5], [6, 6, 6, 6]]
8083 assert data == expected
8184 data = list(b["Sheet3"].rows())
82 expected = [[u'X', u'Y', u'Z'], [1, 4, 7], [2, 5, 8], [3, 6, 9]]
85 expected = [[u"X", u"Y", u"Z"], [1, 4, 7], [2, 5, 8], [3, 6, 9]]
8386 assert data == expected
8487 sheet3 = b["Sheet3"]
8588 sheet3.name_columns_by_row(0)
8992
9093
9194 class ODSCellTypes:
92
9395 def test_formats(self):
9496 # date formats
9597 date_format = "%d/%m/%Y"
103105 eq_(self.data["Sheet1"][1][1].strftime(time_format), "12:12:11")
104106 eq_(self.data["Sheet1"][2][1].strftime(time_format), "12:00:00")
105107 eq_(self.data["Sheet1"][3][1], 0)
106 eq_(self.data["Sheet1"][4][1], datetime.timedelta(hours=27,
107 minutes=17,
108 seconds=54))
108 eq_(
109 self.data["Sheet1"][4][1],
110 datetime.timedelta(hours=27, minutes=17, seconds=54),
111 )
109112 eq_(self.data["Sheet1"][5][1], "Other")
110113 # boolean
111114 eq_(self.data["Sheet1"][0][2], "Boolean")
116119 eq_(self.data["Sheet1"][1][3], 11.11)
117120 # Currency
118121 eq_(self.data["Sheet1"][0][4], "Currency")
119 eq_(self.data["Sheet1"][1][4], '1 GBP')
120 eq_(self.data["Sheet1"][2][4], '-10000 GBP')
122 eq_(self.data["Sheet1"][1][4], "1 GBP")
123 eq_(self.data["Sheet1"][2][4], "-10000 GBP")
121124 # Percentage
122125 eq_(self.data["Sheet1"][0][5], "Percentage")
123126 eq_(self.data["Sheet1"][1][5], 2)
22 codecov
33 coverage
44 flake8
5 moban
6 black;python_version>="3.6"
7 isort;python_version>="3.6"
58 psutil
69 pyexcel
710 pyexcel-xls
00 #!/usr/bin/python
11 # -*- encoding: utf-8 -*-
22 import os
3
4 from nose import SkipTest
5 from nose.tools import eq_, raises
6
37 import psutil
48 import pyexcel as pe
9 from pyexcel_io.exceptions import IntegerAccuracyLossError
510 from pyexcel_ods import get_data, save_data
6 from nose.tools import raises, eq_
7 from nose import SkipTest
811
9 IN_TRAVIS = 'TRAVIS' in os.environ
12 IN_TRAVIS = "TRAVIS" in os.environ
1013
1114
1215 def test_bug_fix_for_issue_1():
1316 data = get_data(get_fixtures("repeated.ods"))
14 eq_(data["Sheet1"], [['repeated', 'repeated', 'repeated', 'repeated']])
17 eq_(data["Sheet1"], [["repeated", "repeated", "repeated", "repeated"]])
1518
1619
1720 def test_bug_fix_for_issue_2():
2023 data.update({"Sheet 2": [[u"row 1", u"Héllô!", u"HolÁ!"]]})
2124 save_data("your_file.ods", data)
2225 new_data = get_data("your_file.ods")
23 assert new_data["Sheet 2"] == [[u'row 1', u'H\xe9ll\xf4!', u'Hol\xc1!']]
26 assert new_data["Sheet 2"] == [[u"row 1", u"H\xe9ll\xf4!", u"Hol\xc1!"]]
2427
2528
2629 @raises(Exception)
2730 def test_invalid_date():
2831 from pyexcel_ods.ods import date_value
32
2933 value = "2015-08-"
3034 date_value(value)
3135
3337 @raises(Exception)
3438 def test_fake_date_time_10():
3539 from pyexcel_ods.ods import date_value
40
3641 date_value("1234567890")
3742
3843
3944 @raises(Exception)
4045 def test_fake_date_time_19():
4146 from pyexcel_ods.ods import date_value
47
4248 date_value("1234567890123456789")
4349
4450
4551 @raises(Exception)
4652 def test_fake_date_time_20():
4753 from pyexcel_ods.ods import date_value
54
4855 date_value("12345678901234567890")
4956
5057
5158 def test_issue_13():
5259 test_file = "test_issue_13.ods"
53 data = [
54 [1, 2],
55 [],
56 [],
57 [],
58 [3, 4]
59 ]
60 data = [[1, 2], [], [], [], [3, 4]]
6061 save_data(test_file, {test_file: data})
6162 written_data = get_data(test_file, skip_empty_rows=False)
6263 eq_(data, written_data[test_file])
6667 def test_issue_14():
6768 # pyexcel issue 61
6869 test_file = "issue_61.ods"
69 data = get_data(get_fixtures(test_file),
70 skip_empty_rows=True)
71 eq_(data['S-LMC'], [[u'aaa'], [0]])
70 data = get_data(get_fixtures(test_file), skip_empty_rows=True)
71 eq_(data["S-LMC"], [[u"aaa"], [0]])
7272
7373
7474 def test_issue_6():
7575 test_file = "12_day_as_time.ods"
76 data = get_data(get_fixtures(test_file),
77 skip_empty_rows=True)
78 eq_(data['Sheet1'][0][0].days, 12)
76 data = get_data(get_fixtures(test_file), skip_empty_rows=True)
77 eq_(data["Sheet1"][0][0].days, 12)
7978
8079
8180 def test_issue_19():
8281 test_file = "pyexcel_81_ods_19.ods"
83 data = get_data(get_fixtures(test_file),
84 skip_empty_rows=True)
85 eq_(data['product.template'][1][1], 'PRODUCT NAME PMP')
82 data = get_data(get_fixtures(test_file), skip_empty_rows=True)
83 eq_(data["product.template"][1][1], "PRODUCT NAME PMP")
8684
8785
8886 def test_issue_83_ods_file_handle():
9391 open_files_l1 = proc.open_files()
9492
9593 # start with a csv file
96 data = pe.iget_array(file_name=test_file, library='pyexcel-ods')
94 data = pe.iget_array(file_name=test_file, library="pyexcel-ods")
9795 open_files_l2 = proc.open_files()
9896 delta = len(open_files_l2) - len(open_files_l1)
9997 # cannot catch open file handle
117115 def test_pr_22():
118116 test_file = get_fixtures("white_space.ods")
119117 data = get_data(test_file)
120 # OrderedDict([(u'Sheet1', [[u'paragraph with tab, space, new line']])])
121 eq_(data['Sheet1'][0][0], 'paragraph with tab(\t), space, \nnew line')
118 eq_(data["Sheet1"][0][0], "paragraph with tab(\t), space, \nnew line")
122119
123120
124121 def test_issue_23():
125122 if not IN_TRAVIS:
126123 raise SkipTest()
127 pe.get_book(url="https://github.com/pyexcel/pyexcel-ods/raw/master/tests/fixtures/white_space.ods"); # flake8: noqa
124 pe.get_book(
125 url=(
126 "https://github.com/pyexcel/pyexcel-ods/"
127 + "raw/master/tests/fixtures/white_space.ods"
128 )
129 )
130
131
132 def test_issue_24():
133 test_file = get_fixtures("comment-in-cell.ods")
134 data = get_data(test_file)
135 eq_(data["Sheet1"], [["test"]])
136
137
138 def test_issue_27():
139 test_file = get_fixtures("issue_27.ods")
140 data = get_data(test_file, skip_empty_rows=True)
141 eq_(data["VGPMX"], [["", "Cost Basis", "0"]])
142
143
144 def test_issue_30():
145 test_file = "issue_30.ods"
146 sheet = pe.Sheet()
147 sheet[0, 0] = 999999999999999
148 sheet.save_as(test_file)
149 sheet2 = pe.get_sheet(file_name=test_file)
150 eq_(sheet[0, 0], sheet2[0, 0])
151 os.unlink(test_file)
152
153
154 @raises(IntegerAccuracyLossError)
155 def test_issue_30_precision_loss():
156 test_file = "issue_30_2.ods"
157 sheet = pe.Sheet()
158 sheet[0, 0] = 9999999999999999
159 sheet.save_as(test_file)
128160
129161
130162 def get_fixtures(filename):
00 import os
11
2 from nose.tools import eq_
3
24 from pyexcel_io import get_data, save_data
3 from nose.tools import eq_
45
56
67 class TestFilter:
1213 [3, 23, 33],
1314 [4, 24, 34],
1415 [5, 25, 35],
15 [6, 26, 36]
16 [6, 26, 36],
1617 ]
1718 save_data(self.test_file, sample)
1819 self.sheet_name = "pyexcel_sheet1"
1920
2021 def test_filter_row(self):
21 filtered_data = get_data(self.test_file, start_row=3,
22 library="pyexcel-ods")
22 filtered_data = get_data(
23 self.test_file, start_row=3, library="pyexcel-ods"
24 )
2325 expected = [[4, 24, 34], [5, 25, 35], [6, 26, 36]]
2426 eq_(filtered_data[self.sheet_name], expected)
2527
2628 def test_filter_row_2(self):
27 filtered_data = get_data(self.test_file, start_row=3, row_limit=1,
28 library="pyexcel-ods")
29 filtered_data = get_data(
30 self.test_file, start_row=3, row_limit=1, library="pyexcel-ods"
31 )
2932 expected = [[4, 24, 34]]
3033 eq_(filtered_data[self.sheet_name], expected)
3134
3235 def test_filter_column(self):
33 filtered_data = get_data(self.test_file, start_column=1,
34 library="pyexcel-ods")
35 expected = [[21, 31], [22, 32], [23, 33],
36 [24, 34], [25, 35], [26, 36]]
36 filtered_data = get_data(
37 self.test_file, start_column=1, library="pyexcel-ods"
38 )
39 expected = [[21, 31], [22, 32], [23, 33], [24, 34], [25, 35], [26, 36]]
3740 eq_(filtered_data[self.sheet_name], expected)
3841
3942 def test_filter_column_2(self):
40 filtered_data = get_data(self.test_file,
41 start_column=1, column_limit=1,
42 library="pyexcel-ods")
43 filtered_data = get_data(
44 self.test_file,
45 start_column=1,
46 column_limit=1,
47 library="pyexcel-ods",
48 )
4349 expected = [[21], [22], [23], [24], [25], [26]]
4450 eq_(filtered_data[self.sheet_name], expected)
4551
4652 def test_filter_both_ways(self):
47 filtered_data = get_data(self.test_file,
48 start_column=1, start_row=3,
49 library="pyexcel-ods")
53 filtered_data = get_data(
54 self.test_file, start_column=1, start_row=3, library="pyexcel-ods"
55 )
5056 expected = [[24, 34], [25, 35], [26, 36]]
5157 eq_(filtered_data[self.sheet_name], expected)
5258
5359 def test_filter_both_ways_2(self):
54 filtered_data = get_data(self.test_file,
55 start_column=1, column_limit=1,
56 start_row=3, row_limit=1,
57 library="pyexcel-ods")
60 filtered_data = get_data(
61 self.test_file,
62 start_column=1,
63 column_limit=1,
64 start_row=3,
65 row_limit=1,
66 library="pyexcel-ods",
67 )
5868 expected = [[24]]
5969 eq_(filtered_data[self.sheet_name], expected)
6070
00 import os
11 from textwrap import dedent
2
23 from nose.tools import eq_
34
45 import pyexcel as pe
89 def setUp(self):
910 self.content = [[1, 2, 3.1]]
1011 self.test_file = "test_auto_detect_init.ods"
11 pe.save_as(
12 array=self.content, dest_file_name=self.test_file
13 )
12 pe.save_as(array=self.content, dest_file_name=self.test_file)
1413
1514 def test_auto_detect_int(self):
1615 sheet = pe.get_sheet(file_name=self.test_file, library="pyexcel-ods")
17 expected = dedent("""
16 expected = dedent(
17 """
1818 pyexcel_sheet1:
1919 +---+---+-----+
2020 | 1 | 2 | 3.1 |
21 +---+---+-----+""").strip()
21 +---+---+-----+"""
22 ).strip()
2223 eq_(str(sheet), expected)
2324
2425 def test_get_book_auto_detect_int(self):
2526 book = pe.get_book(file_name=self.test_file, library="pyexcel-ods")
26 expected = dedent("""
27 expected = dedent(
28 """
2729 pyexcel_sheet1:
2830 +---+---+-----+
2931 | 1 | 2 | 3.1 |
30 +---+---+-----+""").strip()
32 +---+---+-----+"""
33 ).strip()
3134 eq_(str(book), expected)
3235
3336 def test_auto_detect_int_false(self):
34 sheet = pe.get_sheet(file_name=self.test_file, auto_detect_int=False,
35 library="pyexcel-ods")
36 expected = dedent("""
37 sheet = pe.get_sheet(
38 file_name=self.test_file,
39 auto_detect_int=False,
40 library="pyexcel-ods",
41 )
42 expected = dedent(
43 """
3744 pyexcel_sheet1:
3845 +-----+-----+-----+
3946 | 1.0 | 2.0 | 3.1 |
40 +-----+-----+-----+""").strip()
47 +-----+-----+-----+"""
48 ).strip()
4149 eq_(str(sheet), expected)
4250
4351 def test_get_book_auto_detect_int_false(self):
44 book = pe.get_book(file_name=self.test_file, auto_detect_int=False,
45 library="pyexcel-ods")
46 expected = dedent("""
52 book = pe.get_book(
53 file_name=self.test_file,
54 auto_detect_int=False,
55 library="pyexcel-ods",
56 )
57 expected = dedent(
58 """
4759 pyexcel_sheet1:
4860 +-----+-----+-----+
4961 | 1.0 | 2.0 | 3.1 |
50 +-----+-----+-----+""").strip()
62 +-----+-----+-----+"""
63 ).strip()
5164 eq_(str(book), expected)
5265
5366 def tearDown(self):
00 import os
1
12 import pyexcel
23
34
45 def test_reading_multiline_ods():
56 testfile = os.path.join("tests", "fixtures", "multilineods.ods")
67 sheet = pyexcel.get_sheet(file_name=testfile)
7 assert sheet[0, 0] == '1\n2\n3\n4'
8 assert sheet[1, 0] == 'Line 1\n\nLine 2'
8 assert sheet[0, 0] == "1\n2\n3\n4"
9 assert sheet[1, 0] == "Line 1\n\nLine 2"
910
1011
1112 def test_writing_multiline_ods():
00 import os
11 import sys
2
3 from nose.tools import raises
4
25 import pyexcel
3 from nose.tools import raises
46 from base import PyexcelMultipleSheetBase
57
68 if sys.version_info[0] == 2 and sys.version_info[1] < 7:
4143 3,3,3,3
4244 """
4345 self.rows = 3
44 pyexcel.save_book_as(bookdict=self.content,
45 dest_file_name=file)
46 pyexcel.save_book_as(bookdict=self.content, dest_file_name=file)
4647
4748 def setUp(self):
4849 self.testfile = "multiple1.ods"
5455 def test_load_a_single_sheet(self):
5556 b1 = pyexcel.get_book(file_name=self.testfile, sheet_name="Sheet1")
5657 assert len(b1.sheet_names()) == 1
57 assert b1['Sheet1'].to_array() == self.content['Sheet1']
58 assert b1["Sheet1"].to_array() == self.content["Sheet1"]
5859
5960 def test_load_a_single_sheet2(self):
6061 b1 = pyexcel.load_book(self.testfile, sheet_index=0)
6162 assert len(b1.sheet_names()) == 1
62 assert b1['Sheet1'].to_array() == self.content['Sheet1']
63 assert b1["Sheet1"].to_array() == self.content["Sheet1"]
6364
6465 @raises(IndexError)
6566 def test_load_a_single_sheet3(self):
228229 self.testfile = "file_with_an_empty_sheet.ods"
229230
230231 def test_reader_with_correct_sheets(self):
231 r = pyexcel.BookReader(os.path.join("tests", "fixtures",
232 self.testfile))
232 r = pyexcel.BookReader(
233 os.path.join("tests", "fixtures", self.testfile)
234 )
233235 assert r.number_of_sheets() == 3
234236
235237
236238 def _produce_ordered_dict():
237239 data_dict = OrderedDict()
238 data_dict.update({
239 "Sheet1": [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]]})
240 data_dict.update({
241 "Sheet2": [[4, 4, 4, 4], [5, 5, 5, 5], [6, 6, 6, 6]]})
242 data_dict.update({
243 "Sheet3": [[u'X', u'Y', u'Z'], [1, 4, 7], [2, 5, 8], [3, 6, 9]]})
240 data_dict.update({"Sheet1": [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]]})
241 data_dict.update({"Sheet2": [[4, 4, 4, 4], [5, 5, 5, 5], [6, 6, 6, 6]]})
242 data_dict.update(
243 {"Sheet3": [[u"X", u"Y", u"Z"], [1, 4, 7], [2, 5, 8], [3, 6, 9]]}
244 )
244245 return data_dict
00 import os
1
2 from base import ODSCellTypes
13 from pyexcel_ods.odsr import ODSBook
24 from pyexcel_ods.odsw import ODSWriter
3 from base import ODSCellTypes
45
56
67 class TestODSReader(ODSCellTypes):
78 def setUp(self):
89 r = ODSBook()
9 r.open(os.path.join("tests",
10 "fixtures",
11 "ods_formats.ods"))
10 r.open(os.path.join("tests", "fixtures", "ods_formats.ods"))
1211 self.data = r.read_all()
1312 for key in self.data.keys():
1413 self.data[key] = list(self.data[key])
1817 class TestODSWriter(ODSCellTypes):
1918 def setUp(self):
2019 r = ODSBook()
21 r.open(os.path.join("tests",
22 "fixtures",
23 "ods_formats.ods"))
20 r.open(os.path.join("tests", "fixtures", "ods_formats.ods"))
2421 self.data1 = r.read_all()
2522 self.testfile = "odswriter.ods"
2623 w = ODSWriter()
00 import os
1
2 from nose.tools import eq_
3
14 import pyexcel
2 from nose.tools import eq_
35 from base import create_sample_file1
46
57
68 class TestStringIO:
7
89 def test_ods_stringio(self):
910 testfile = "cute.ods"
1011 create_sample_file1(testfile)
1112 with open(testfile, "rb") as f:
1213 content = f.read()
13 r = pyexcel.get_sheet(file_type="ods", file_content=content,
14 library="pyexcel-ods")
15 result = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1.1, 1]
14 r = pyexcel.get_sheet(
15 file_type="ods", file_content=content, library="pyexcel-ods"
16 )
17 result = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", 1.1, 1]
1618 actual = list(r.enumerate())
1719 eq_(result, actual)
1820 if os.path.exists(testfile):
1921 os.unlink(testfile)
2022
2123 def test_ods_output_stringio(self):
22 data = [
23 [1, 2, 3],
24 [4, 5, 6]
25 ]
26 io = pyexcel.save_as(dest_file_type="ods",
27 array=data)
28 r = pyexcel.get_sheet(file_type="ods", file_content=io.getvalue(),
29 library="pyexcel-ods")
24 data = [[1, 2, 3], [4, 5, 6]]
25 io = pyexcel.save_as(dest_file_type="ods", array=data)
26 r = pyexcel.get_sheet(
27 file_type="ods", file_content=io.getvalue(), library="pyexcel-ods"
28 )
3029 result = [1, 2, 3, 4, 5, 6]
3130 actual = list(r.enumerate())
3231 eq_(result, actual)
00 import os
1
2 from base import PyexcelHatWriterBase, PyexcelWriterBase
3 from pyexcel_ods.odsr import ODSBook as Reader
14 from pyexcel_ods.odsw import ODSWriter as Writer
2 from pyexcel_ods.odsr import ODSBook as Reader
3 from base import PyexcelWriterBase, PyexcelHatWriterBase
45
56
67 class TestNativeODSWriter:
89 self.content = {
910 "Sheet1": [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]],
1011 "Sheet2": [[4, 4, 4, 4], [5, 5, 5, 5], [6, 6, 6, 6]],
11 "Sheet3": [[u'X', u'Y', u'Z'], [1, 4, 7], [2, 5, 8], [3, 6, 9]]
12 "Sheet3": [[u"X", u"Y", u"Z"], [1, 4, 7], [2, 5, 8], [3, 6, 9]],
1213 }
1314 self.testfile = "writer.ods"
1415 writer = Writer()