Handle writing tuples
See original GitHub issueI am working with spatial data and the shape format for a point is an x, y tuple. In the worksheet class, the write method tries all of the options to write this tuple and falls through to the part where it tries a float. With my code I get a TypeError
instead of a ValueError
and the application busts without trying the string style. I commented out the float casting and it doesn’t bust on write_row
but then raises a separate error when you close the workbook.
Traceback (most recent call last): File “<string>”, line 1, in <module> File “C:\Python27\ArcGIS10.2\lib\site-packages\xlsxwriter\workbook.py”, line 246, in close self._store_workbook() File “C:\Python27\ArcGIS10.2\lib\site-packages\xlsxwriter\workbook.py”, line 448, in _store_workbook xml_files = packager._create_package() File “C:\Python27\ArcGIS10.2\lib\site-packages\xlsxwriter\packager.py”, line 140, in _create_package self._write_shared_strings_file() File “C:\Python27\ArcGIS10.2\lib\site-packages\xlsxwriter\packager.py”, line 266, in _write_shared_strings_file sst._assemble_xml_file() File “C:\Python27\ArcGIS10.2\lib\site-packages\xlsxwriter\sharedstrings.py”, line 53, in _assemble_xml_file self._write_sst_strings() File “C:\Python27\ArcGIS10.2\lib\site-packages\xlsxwriter\sharedstrings.py”, line 83, in _write_sst_strings self._write_si(string) File “C:\Python27\ArcGIS10.2\lib\site-packages\xlsxwriter\sharedstrings.py”, line 95, in _write_si string = re.sub(‘(x[0-9a-fA-F]{4})’, r’_x005F\1’, string) File “C:\Python27\ArcGIS10.2\Lib\re.py”, line 151, in sub return _compile(pattern, flags).sub(repl, string, count) TypeError: expected string or buffer
is there a way to successfully store tuples or is it expected that I format them how I want them before writing them to the sheet?
Issue Analytics
- State:
- Created 9 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
I am using
I figured this might be your response. I would have just hoped for a better error message.
That looks awesome.