Commit 9c7d2440 by Celine Mercier

export: dictionaries are now formatted like in the original OBITools

when exporting in tabular format and tuple formatting is cleaner
parent 03bc9915
......@@ -3,7 +3,7 @@
cimport cython
from obitools3.dms.view.view cimport Line
from obitools3.utils cimport bytes2str_object, str2bytes, tobytes
from obitools3.dms.column.column cimport Column_line
from obitools3.dms.column.column cimport Column_line, Column_multi_elts
cdef class TabFormat:
......@@ -25,18 +25,28 @@ cdef class TabFormat:
for k in self.tags:
if self.header and self.first_line:
value = tobytes(k)
if isinstance(data.view[k], Column_multi_elts):
for k2 in data.view[k].keys():
line.append(tobytes(k)+b':'+tobytes(k2))
else:
line.append(tobytes(k))
else:
value = data[k]
if isinstance(data.view[k], Column_multi_elts):
if value is None: # all keys at None
for k2 in data.view[k].keys(): # TODO could be much more efficient
line.append(self.NAString)
else:
for k2 in data.view[k].keys(): # TODO could be much more efficient
if value[k2] is not None:
line.append(str2bytes(str(bytes2str_object(value[k2])))) # genius programming
else:
line.append(self.NAString)
else:
if value is not None:
if type(value) == Column_line:
value = value.bytes()
line.append(str2bytes(str(bytes2str_object(value))))
else:
value = str2bytes(str(bytes2str_object(value))) # genius programming
if value is None:
value = self.NAString
line.append(value)
line.append(self.NAString)
if self.first_line:
self.first_line = False
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment