-
-
Notifications
You must be signed in to change notification settings - Fork 13
Description
Hi all,
I use the pyexcel-ods3 and I have a problem. The system can't handle with empty cells and empty sheets.
If you read a file with empty sheet, you get {'SheetName' : []} If you want to write it with odsw.py you get an exception. The system can't write his own generated dict.
The other Problem is that I can't write empty cells, only cells with an empty string. It is not the same, you can see the different. The row 1 has cells with empty strings, the second row has empty cells.
The odsw.py can accept a row ['text','','','other text'] but not ['text',None,None,'other text']
I repared it for myself and I think it can be usefull for others also.
I changed 4 files in 3 projects. They are the service.py in the pyexcel.io; cells.py in the pyexcel-ezodf; the odsr.py and odsw.py in the pyexcel-ods3.
The service.py in pyexcel-io is the deepest place. I need there in the dict ODS_WRITE_FORMAT_COVERSION a new item in the row 178: type(None): "nothing",
I inserted in pyexcel-ezodf/ezodf in the file cells.py in the rows 78, 79 (or only in the line 78 if you like it) elif t == 'nothing': result = None The value will be None if the cell is empty, and you don't get "" back any more. If you have 3 empty cells in a row, then you get [None,None,None,'text'] and not ['','','','text']
The line 55 in the file odsr.py is only ret = cell.value The None value should pass through here.
I made 2 changes in the file odsw.py:
I inserted after the columns = max([len(row) for row in to_write_data]) in the line 73 and 74 a if columns <1: return
It is because of empty sheets.
In the lines 60,61 I make the set_value only if not value_type == "nothing": so the function leave the cells empty, if the element in the list is None.
Here are the changed files:
changes.zip
The changes will work only thogether, so you have commit at the same time, and edit dependency.
best regards
Zsolt