Commit 3d1b2e8e by Celine Mercier

Better handling of column lines with all values at NA

parent ae5f42c2
......@@ -491,7 +491,7 @@ cdef class Column_multi_elts(Column) :
cdef object values_iter
if not self.active() :
raise OBIDeactivatedInstanceError()
if values is None or len(values) == 0 :
if values is None or len(values) == 0 or (isinstance(values, Column_line) and values.is_NA()):
for element_name in self._elements_names :
self.set_item(line_nb, element_name, None)
else :
......@@ -539,6 +539,10 @@ cdef class Column_line :
def __repr__(self) :
return str(self._column.get_line(self._index))
def is_NA(self):
return self._column.get_line(self._index) is None
def __iter__(self) :
cdef list elements_names
......@@ -569,6 +573,8 @@ cdef class Column_line :
def __str__(self):
cdef dict d
cdef str s
if self.is_NA():
return ""
d = {}
for k,v in self.items():
if type(v) == bytes:
......
......@@ -56,9 +56,11 @@ cdef class HeaderFormat:
for k in ktags:
if k in tags:
value = data[k]
if value is None:
if value is None or (isinstance(value, Column_line) and value.is_NA()):
if self.printNAKeys:
value = self.NAString
else:
value = None
else:
if type(value) == Column_line:
value = value.bytes()
......
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