Commit 0eaa5aa7 by Celine Mercier

Major changes : new cython subclasses to handle columns with multiple

elements per line in a more efficient way + now elements_names are
passed as a list + new function to recover only the header of a column
parent 21923e21
......@@ -23,22 +23,24 @@ cdef class OBIDMS:
OBIType_t data_type=*,
size_t nb_lines=*,
size_t nb_elements_per_line=*,
str elements_names=*)
list elements_names=*)
cdef class OBIDMS_column:
cdef OBIDMS_column_p pointer
cdef OBIDMS dms
cdef str data_type # TODO keep as OBIType_t? both?
cdef str dms_name
cdef str column_name
cdef OBIDMS_column_p pointer
cdef OBIDMS dms
cdef str data_type # TODO keep as OBIType_t? both?
cdef str dms_name
cdef str column_name
cdef size_t nb_elements_per_line
cdef list elements_names
cpdef object get_item(self, size_t line_nb, str element_name)
# cpdef object get_item(self, size_t line_nb, str element_name) TODO can't declare because not the same in all subclasses
# cpdef set_item(self, size_t line_nb, str element_name, object value) TODO can't declare because object value
cpdef list get_elements_names(self)
cpdef str get_data_type(self)
cpdef size_t get_nb_lines_used(self)
cpdef str get_creation_date(self)
# cpdef str get_creation_date(self)
cpdef close(self)
#cython: language_level=3
from .capi.obitypes cimport obibool_t
from .capi.obidmscolumn cimport OBIDMS_column_p
from ._obidms cimport OBIDMS_column
from ._obidms cimport OBIDMS_column
cdef class OBIDMS_column_bool(OBIDMS_column):
cpdef object get_line(self, size_t line_nb)
cpdef set_line(self, size_t line_nb, object value)
cpdef close(self)
cdef class OBIDMS_column_bool_writable(OBIDMS_column_bool):
cpdef set_line(self, size_t line_nb, object value)
cpdef close(self)
cdef class OBIDMS_column_bool_multi_elts(OBIDMS_column_bool):
cpdef object get_item(self, size_t line_nb, str element_name)
cpdef object get_line(self, size_t line_nb)
cpdef set_item(self, size_t line_nb, str element_name, obibool_t value)
cpdef close(self)
cpdef set_line(self, size_t line_nb, object values)
cdef class OBIDMS_column_bool_writable(OBIDMS_column_bool):
cdef class OBIDMS_column_bool_multi_elts_writable(OBIDMS_column_bool_multi_elts):
cpdef set_item(self, size_t line_nb, str element_name, obibool_t value)
cpdef set_line(self, size_t line_nb, object values)
cpdef close(self)
......@@ -3,7 +3,9 @@
from .capi.obidmscolumn cimport obi_close_column,\
obi_truncate_and_close_column, \
obi_column_get_obibool_with_elt_name, \
obi_column_set_obibool_with_elt_name
obi_column_get_obibool_with_elt_idx, \
obi_column_set_obibool_with_elt_name, \
obi_column_set_obibool_with_elt_idx
from .capi.obierrno cimport obi_errno
from .capi.obitypes cimport OBIBool_NA
......@@ -13,34 +15,90 @@ from cpython.bool cimport PyBool_FromLong
cdef class OBIDMS_column_bool(OBIDMS_column):
cpdef object get_item(self, size_t line_nb, str element_name):
cpdef object get_line(self, size_t line_nb):
cdef obibool_t value
cdef object result
value = obi_column_get_obibool_with_elt_name(self.pointer, line_nb, str2bytes(element_name))
value = obi_column_get_obibool_with_elt_idx(self.pointer, line_nb, 0)
if obi_errno > 0 :
raise IndexError(line_nb, element_name)
raise IndexError(line_nb)
if value == OBIBool_NA :
result = None
else :
result = PyBool_FromLong(value)
return result
cpdef set_item(self, size_t line_nb, str element_name, obibool_t value):
cpdef set_line(self, size_t line_nb, object value):
raise Exception("Column is read-only")
cpdef close(self):
if obi_close_column(self.pointer) < 0 :
raise Exception("Problem closing a column")
cdef class OBIDMS_column_bool_writable(OBIDMS_column_bool):
cpdef set_line(self, size_t line_nb, object value):
if obi_column_set_obibool_with_elt_idx(self.pointer, line_nb, 0, <obibool_t> value) < 0:
raise Exception("Problem setting a value in a column")
cpdef close(self):
if obi_truncate_and_close_column(self.pointer) < 0 :
raise Exception("Problem closing a column")
cdef class OBIDMS_column_bool_multi_elts(OBIDMS_column_bool):
cpdef object get_item(self, size_t line_nb, str element_name):
cdef obibool_t value
cdef object result
value = obi_column_get_obibool_with_elt_name(self.pointer, line_nb, str2bytes(element_name))
if obi_errno > 0 :
raise IndexError(line_nb, element_name)
if value == OBIBool_NA :
result = None
else :
result = PyBool_FromLong(value)
return result
cpdef object get_line(self, size_t line_nb) :
cdef obibool_t value
cdef object result
cdef size_t i
cdef bint all_NA
result = {}
all_NA = True
for i in range(self.nb_elements_per_line) :
value = obi_column_get_obibool_with_elt_idx(self.pointer, line_nb, i)
if obi_errno > 0 :
raise IndexError(line_nb)
result[self.elements_names[i]] = PyBool_FromLong(value)
if all_NA and (value != OBIBool_NA) :
all_NA = False
if all_NA :
result = None
return result
cpdef set_item(self, size_t line_nb, str element_name, obibool_t value):
if obi_column_set_obibool_with_elt_name(self.pointer, line_nb, str2bytes(element_name), value) < 0 :
raise Exception("Column is read-only")
cpdef set_line(self, size_t line_nb, object values):
raise Exception("Column is read-only")
cdef class OBIDMS_column_bool_multi_elts_writable(OBIDMS_column_bool_multi_elts):
cpdef set_item(self, size_t line_nb, str element_name, obibool_t value):
if obi_column_set_obibool_with_elt_name(self.pointer, line_nb, str2bytes(element_name), value) < 0:
raise Exception("Problem setting a value in a column")
cpdef set_line(self, size_t line_nb, object values):
cdef obibool_t value
for element_name in values :
value = <obibool_t> values[element_name]
self.set_item(line_nb, element_name, value)
cpdef close(self):
if obi_truncate_and_close_column(self.pointer) < 0 :
raise Exception("Problem closing a column")
\ No newline at end of file
#cython: language_level=3
from .capi.obitypes cimport obichar_t
from .capi.obidmscolumn cimport OBIDMS_column_p
from ._obidms cimport OBIDMS_column
from ._obidms cimport OBIDMS_column
cdef class OBIDMS_column_char(OBIDMS_column):
cpdef object get_line(self, size_t line_nb)
cpdef set_line(self, size_t line_nb, object value)
cpdef close(self)
cdef class OBIDMS_column_char_writable(OBIDMS_column_char):
cpdef set_line(self, size_t line_nb, object value)
cpdef close(self)
cdef class OBIDMS_column_char_multi_elts(OBIDMS_column_char):
cpdef object get_item(self, size_t line_nb, str element_name)
cpdef object get_line(self, size_t line_nb)
cpdef set_item(self, size_t line_nb, str element_name, bytes value)
cpdef close(self)
cpdef set_line(self, size_t line_nb, object values)
cdef class OBIDMS_column_char_writable(OBIDMS_column_char):
cdef class OBIDMS_column_char_multi_elts_writable(OBIDMS_column_char_multi_elts):
cpdef set_item(self, size_t line_nb, str element_name, bytes value)
cpdef set_line(self, size_t line_nb, object values)
cpdef close(self)
......@@ -3,17 +3,52 @@
from .capi.obidmscolumn cimport obi_close_column,\
obi_truncate_and_close_column, \
obi_column_get_obichar_with_elt_name, \
obi_column_set_obichar_with_elt_name
obi_column_get_obichar_with_elt_idx, \
obi_column_set_obichar_with_elt_name, \
obi_column_set_obichar_with_elt_idx
from .capi.obierrno cimport obi_errno
from .capi.obitypes cimport OBIChar_NA
from obitools3.utils cimport str2bytes
cdef class OBIDMS_column_char(OBIDMS_column) :
cdef class OBIDMS_column_char(OBIDMS_column):
cpdef object get_line(self, size_t line_nb):
cdef obichar_t value
cdef object result
value = obi_column_get_obichar_with_elt_idx(self.pointer, line_nb, 0)
if obi_errno > 0 :
raise IndexError(line_nb)
if value == OBIChar_NA :
result = None
else :
result = <bytes> value
return result
cpdef set_line(self, size_t line_nb, object value):
raise Exception("Column is read-only")
cpdef close(self):
if obi_close_column(self.pointer) < 0 :
raise Exception("Problem closing a column")
cdef class OBIDMS_column_char_writable(OBIDMS_column_char):
cpdef set_line(self, size_t line_nb, object value):
if obi_column_set_obichar_with_elt_idx(self.pointer, line_nb, 0, <bytes> value[0]) < 0:
raise Exception("Problem setting a value in a column")
cpdef close(self):
if obi_truncate_and_close_column(self.pointer) < 0 :
raise Exception("Problem closing a column")
cdef class OBIDMS_column_char_multi_elts(OBIDMS_column_char):
cpdef object get_item(self, size_t line_nb, str element_name):
cdef char value
cdef obichar_t value
cdef object result
value = obi_column_get_obichar_with_elt_name(self.pointer, line_nb, str2bytes(element_name))
if obi_errno > 0 :
......@@ -23,22 +58,81 @@ cdef class OBIDMS_column_char(OBIDMS_column) :
else :
result = <bytes> value
return result
cpdef object get_line(self, size_t line_nb) :
cdef obichar_t value
cdef object result
cdef size_t i
cdef bint all_NA
result = {}
all_NA = True
for i in range(self.nb_elements_per_line) :
value = obi_column_get_obichar_with_elt_idx(self.pointer, line_nb, i)
if obi_errno > 0 :
raise IndexError(line_nb)
result[self.elements_names[i]] = <bytes> value
if all_NA and (value != OBIChar_NA) :
all_NA = False
if all_NA :
result = None
return result
cpdef set_item(self, size_t line_nb, str element_name, bytes value):
raise Exception("Column is read-only")
cpdef close(self):
if obi_close_column(self.pointer) < 0 :
raise Exception("Problem closing a column")
cdef class OBIDMS_column_char_writable(OBIDMS_column_char) :
cpdef set_line(self, size_t line_nb, object values):
raise Exception("Column is read-only")
cdef class OBIDMS_column_char_multi_elts_writable(OBIDMS_column_char_multi_elts):
cpdef set_item(self, size_t line_nb, str element_name, bytes value):
if obi_column_set_obichar_with_elt_name(self.pointer, line_nb, str2bytes(element_name), value[0]) < 0:
raise Exception("Problem setting a value in a column")
cpdef set_line(self, size_t line_nb, object values):
cdef bytes value
for element_name in values :
value = <bytes> values[element_name]
self.set_item(line_nb, element_name, value)
cpdef close(self):
if obi_truncate_and_close_column(self.pointer) < 0 :
raise Exception("Problem closing a column")
# cdef class OBIDMS_column_char(OBIDMS_column) :
#
# cpdef object get_item(self, size_t line_nb, str element_name):
# cdef char value
# cdef object result
# value = obi_column_get_obichar_with_elt_name(self.pointer, line_nb, str2bytes(element_name))
# if obi_errno > 0 :
# raise IndexError(line_nb, element_name)
# if value == OBIChar_NA :
# result = None
# else :
# result = <bytes> value
# return result
#
# cpdef set_item(self, size_t line_nb, str element_name, bytes value):
# raise Exception("Column is read-only")
#
# cpdef close(self):
# if obi_close_column(self.pointer) < 0 :
# raise Exception("Problem closing a column")
#
#
# cdef class OBIDMS_column_char_writable(OBIDMS_column_char) :
#
# cpdef set_item(self, size_t line_nb, str element_name, bytes value):
# if obi_column_set_obichar_with_elt_name(self.pointer, line_nb, str2bytes(element_name), value[0]) < 0:
# raise Exception("Problem setting a value in a column")
#
# cpdef close(self):
# if obi_truncate_and_close_column(self.pointer) < 0 :
# raise Exception("Problem closing a column")
#
#cython: language_level=3
from .capi.obitypes cimport obifloat_t
from .capi.obidmscolumn cimport OBIDMS_column_p
from ._obidms cimport OBIDMS_column
from ._obidms cimport OBIDMS_column
cdef class OBIDMS_column_float(OBIDMS_column):
cpdef object get_line(self, size_t line_nb)
cpdef set_line(self, size_t line_nb, object value)
cpdef close(self)
cdef class OBIDMS_column_float_writable(OBIDMS_column_float):
cpdef set_line(self, size_t line_nb, object value)
cpdef close(self)
cdef class OBIDMS_column_float_multi_elts(OBIDMS_column_float):
cpdef object get_item(self, size_t line_nb, str element_name)
cpdef object get_line(self, size_t line_nb)
cpdef set_item(self, size_t line_nb, str element_name, obifloat_t value)
cpdef close(self)
cdef class OBIDMS_column_float_writable(OBIDMS_column_float):
cpdef set_line(self, size_t line_nb, object values)
cdef class OBIDMS_column_float_multi_elts_writable(OBIDMS_column_float_multi_elts):
cpdef set_item(self, size_t line_nb, str element_name, obifloat_t value)
cpdef set_line(self, size_t line_nb, object values)
cpdef close(self)
......@@ -3,7 +3,9 @@
from .capi.obidmscolumn cimport obi_close_column,\
obi_truncate_and_close_column, \
obi_column_get_obifloat_with_elt_name, \
obi_column_set_obifloat_with_elt_name
obi_column_get_obifloat_with_elt_idx, \
obi_column_set_obifloat_with_elt_name, \
obi_column_set_obifloat_with_elt_idx
from .capi.obierrno cimport obi_errno
from .capi.obitypes cimport OBIFloat_NA
......@@ -12,6 +14,39 @@ from obitools3.utils cimport str2bytes
cdef class OBIDMS_column_float(OBIDMS_column):
cpdef object get_line(self, size_t line_nb):
cdef obifloat_t value
cdef object result
value = obi_column_get_obifloat_with_elt_idx(self.pointer, line_nb, 0)
if obi_errno > 0 :
raise IndexError(line_nb)
if value == OBIFloat_NA :
result = None
else :
result = <double> value
return result
cpdef set_line(self, size_t line_nb, object value):
raise Exception("Column is read-only")
cpdef close(self):
if obi_close_column(self.pointer) < 0 :
raise Exception("Problem closing a column")
cdef class OBIDMS_column_float_writable(OBIDMS_column_float):
cpdef set_line(self, size_t line_nb, object value):
if obi_column_set_obifloat_with_elt_idx(self.pointer, line_nb, 0, <obifloat_t> value) < 0:
raise Exception("Problem setting a value in a column")
cpdef close(self):
if obi_truncate_and_close_column(self.pointer) < 0 :
raise Exception("Problem closing a column")
cdef class OBIDMS_column_float_multi_elts(OBIDMS_column_float):
cpdef object get_item(self, size_t line_nb, str element_name):
cdef obifloat_t value
cdef object result
......@@ -24,21 +59,45 @@ cdef class OBIDMS_column_float(OBIDMS_column):
result = <double> value
return result
cpdef object get_line(self, size_t line_nb) :
cdef obifloat_t value
cdef object result
cdef size_t i
cdef bint all_NA
result = {}
all_NA = True
for i in range(self.nb_elements_per_line) :
value = obi_column_get_obifloat_with_elt_idx(self.pointer, line_nb, i)
if obi_errno > 0 :
raise IndexError(line_nb)
result[self.elements_names[i]] = <double> value
if all_NA and (value != OBIFloat_NA) :
all_NA = False
if all_NA :
result = None
return result
cpdef set_item(self, size_t line_nb, str element_name, obifloat_t value):
raise Exception("Column is read-only")
cpdef close(self):
if obi_close_column(self.pointer) < 0 :
raise Exception("Problem closing a column")
cpdef set_line(self, size_t line_nb, object values):
raise Exception("Column is read-only")
cdef class OBIDMS_column_float_writable(OBIDMS_column_float):
cdef class OBIDMS_column_float_multi_elts_writable(OBIDMS_column_float_multi_elts):
cpdef set_item(self, size_t line_nb, str element_name, obifloat_t value):
if obi_column_set_obifloat_with_elt_name(self.pointer, line_nb, str2bytes(element_name), value) < 0:
raise Exception("Problem setting a value in a column")
cpdef set_line(self, size_t line_nb, object values):
cdef obifloat_t value
for element_name in values :
value = <obifloat_t> values[element_name]
self.set_item(line_nb, element_name, value)
cpdef close(self):
if obi_truncate_and_close_column(self.pointer) < 0 :
raise Exception("Problem closing a column")
\ No newline at end of file
#cython: language_level=3
from .capi.obitypes cimport obiidx_t
from .capi.obidmscolumn cimport OBIDMS_column_p
from ._obidms cimport OBIDMS_column
from ._obidms cimport OBIDMS_column
cdef class OBIDMS_column_idx(OBIDMS_column):
cpdef object get_line(self, size_t line_nb)
cpdef set_line(self, size_t line_nb, object value)
cpdef close(self)
cdef class OBIDMS_column_idx_writable(OBIDMS_column_idx):
cpdef set_line(self, size_t line_nb, object value)
cpdef close(self)
cdef class OBIDMS_column_idx_multi_elts(OBIDMS_column_idx):
cpdef object get_item(self, size_t line_nb, str element_name)
cpdef object get_line(self, size_t line_nb)
cpdef set_item(self, size_t line_nb, str element_name, obiidx_t value)
cpdef close(self)
cdef class OBIDMS_column_idx_writable(OBIDMS_column_idx):
cpdef set_line(self, size_t line_nb, object values)
cdef class OBIDMS_column_idx_multi_elts_writable(OBIDMS_column_idx_multi_elts):
cpdef set_item(self, size_t line_nb, str element_name, obiidx_t value)
cpdef set_line(self, size_t line_nb, object values)
cpdef close(self)
#cython: language_level=3
from .capi.obidmscolumn cimport obi_close_column,\
obi_truncate_and_close_column, \
obi_column_get_obiidx_with_elt_name, \
obi_column_set_obiidx_with_elt_name
obi_column_get_obiidx_with_elt_idx, \
obi_column_set_obiidx_with_elt_name, \
obi_column_set_obiidx_with_elt_idx
from .capi.obierrno cimport obi_errno
from .capi.obitypes cimport OBIIdx_NA
......@@ -14,6 +16,39 @@ from cpython.int cimport PyInt_FromSsize_t
cdef class OBIDMS_column_idx(OBIDMS_column):
cpdef object get_line(self, size_t line_nb):
cdef obiidx_t value
cdef object result
value = obi_column_get_obiidx_with_elt_idx(self.pointer, line_nb, 0)
if obi_errno > 0 :
raise IndexError(line_nb)
if value == OBIIdx_NA :
result = None
else :
result = PyInt_FromSsize_t(value)
return result
cpdef set_line(self, size_t line_nb, object value):
raise Exception("Column is read-only")
cpdef close(self):
if obi_close_column(self.pointer) < 0 :
raise Exception("Problem closing a column")
cdef class OBIDMS_column_idx_writable(OBIDMS_column_idx):
cpdef set_line(self, size_t line_nb, object value):
if obi_column_set_obiidx_with_elt_idx(self.pointer, line_nb, 0, <obiidx_t> value) < 0:
raise Exception("Problem setting a value in a column")
cpdef close(self):
if obi_truncate_and_close_column(self.pointer) < 0 :
raise Exception("Problem closing a column")
cdef class OBIDMS_column_idx_multi_elts(OBIDMS_column_idx):
cpdef object get_item(self, size_t line_nb, str element_name):
cdef obiidx_t value
cdef object result
......@@ -26,21 +61,45 @@ cdef class OBIDMS_column_idx(OBIDMS_column):
result = PyInt_FromSsize_t(value)
return result
cpdef object get_line(self, size_t line_nb) :
cdef obiidx_t value
cdef object result
cdef size_t i
cdef bint all_NA
result = {}
all_NA = True
for i in range(self.nb_elements_per_line) :
value = obi_column_get_obiidx_with_elt_idx(self.pointer, line_nb, i)
if obi_errno > 0 :
raise IndexError(line_nb)
result[self.elements_names[i]] = PyInt_FromSsize_t(value)
if all_NA and (value != OBIIdx_NA) :
all_NA = False
if all_NA :
result = None
return result
cpdef set_item(self, size_t line_nb, str element_name, obiidx_t value):
raise Exception("Column is read-only")
cpdef close(self):
if obi_close_column(self.pointer) < 0 :
raise Exception("Problem closing a column")
cpdef set_line(self, size_t line_nb, object values):
raise Exception("Column is read-only")
cdef class OBIDMS_column_idx_writable(OBIDMS_column_idx):
cdef class OBIDMS_column_idx_multi_elts_writable(OBIDMS_column_idx_multi_elts):
cpdef set_item(self, size_t line_nb, str element_name, obiidx_t value):
if obi_column_set_obiidx_with_elt_name(self.pointer, line_nb, str2bytes(element_name), value) < 0:
raise Exception("Problem setting a value in a column")
cpdef set_line(self, size_t line_nb, object values):
cdef obiidx_t value
for element_name in values :
value = <obiidx_t> values[element_name]
self.set_item(line_nb, element_name, value)
cpdef close(self):
if obi_truncate_and_close_column(self.pointer) < 0 :
raise Exception("Problem closing a column")
\ No newline at end of file
#cython: language_level=3
from .capi.obitypes cimport obiint_t
from .capi.obidmscolumn cimport OBIDMS_column_p
from ._obidms cimport OBIDMS_column
from ._obidms cimport OBIDMS_column
cdef class OBIDMS_column_int(OBIDMS_column):
cpdef object get_line(self, size_t line_nb)
cpdef set_line(self, size_t line_nb, object value)
cpdef close(self)
cdef class OBIDMS_column_int_writable(OBIDMS_column_int):
cpdef set_line(self, size_t line_nb, object value)
cpdef close(self)
cdef class OBIDMS_column_int_multi_elts(OBIDMS_column_int):
cpdef object get_item(self, size_t line_nb, str element_name)
cpdef object get_line(self, size_t line_nb)
cpdef set_item(self, size_t line_nb, str element_name, obiint_t value)
cpdef close(self)
cdef class OBIDMS_column_int_writable(OBIDMS_column_int):
cpdef set_line(self, size_t line_nb, object values)
cdef class OBIDMS_column_int_multi_elts_writable(OBIDMS_column_int_multi_elts):
cpdef set_item(self, size_t line_nb, str element_name, obiint_t value)
cpdef set_line(self, size_t line_nb, object values)
cpdef close(self)
......@@ -3,7 +3,9 @@
from .capi.obidmscolumn cimport obi_close_column,\
obi_truncate_and_close_column, \
obi_column_get_obiint_with_elt_name, \
obi_column_set_obiint_with_elt_name
obi_column_get_obiint_with_elt_idx, \
obi_column_set_obiint_with_elt_name, \
obi_column_set_obiint_with_elt_idx
from .capi.obierrno cimport obi_errno
from .capi.obitypes cimport OBIInt_NA
......@@ -11,11 +13,42 @@ from obitools3.utils cimport str2bytes
from cpython.int cimport PyInt_FromLong
from ._obidms cimport OBIDMS_column
cdef class OBIDMS_column_int(OBIDMS_column):
cpdef object get_line(self, size_t line_nb):
cdef obiint_t value
cdef object result
value = obi_column_get_obiint_with_elt_idx(self.pointer, line_nb, 0)
if obi_errno > 0 :
raise IndexError(line_nb)
if value == OBIInt_NA :
result = None
else :
result = PyInt_FromLong(value)
return result
cpdef set_line(self, size_t line_nb, object value):
raise Exception("Column is read-only")
cpdef close(self):
if obi_close_column(self.pointer) < 0 :
raise Exception("Problem closing a column")
cdef class OBIDMS_column_int_writable(OBIDMS_column_int):
cpdef set_line(self, size_t line_nb, object value):
if obi_column_set_obiint_with_elt_idx(self.pointer, line_nb, 0, <obiint_t> value) < 0:
raise Exception("Problem setting a value in a column")
cpdef close(self):
if obi_truncate_and_close_column(self.pointer) < 0 :
raise Exception("Problem closing a column")
cdef class OBIDMS_column_int_multi_elts(OBIDMS_column_int):
cpdef object get_item(self, size_t line_nb, str element_name):
cdef obiint_t value
cdef object result
......@@ -28,21 +61,44 @@ cdef class OBIDMS_column_int(OBIDMS_column):
result = PyInt_FromLong(value)
return result
cpdef object get_line(self, size_t line_nb) :
cdef obiint_t value
cdef object result
cdef size_t i
cdef bint all_NA
result = {}
all_NA = True
for i in range(self.nb_elements_per_line) :
value = obi_column_get_obiint_with_elt_idx(self.pointer, line_nb, i)
if obi_errno > 0 :
raise IndexError(line_nb)
result[self.elements_names[i]] = PyInt_FromLong(value)
if all_NA and (value != OBIInt_NA) :
all_NA = False
if all_NA :
result = None
return result
cpdef set_item(self, size_t line_nb, str element_name, obiint_t value):
raise Exception("Column is read-only")
cpdef close(self):
if obi_close_column(self.pointer) < 0 :
raise Exception("Problem closing a column")
cpdef set_line(self, size_t line_nb, object values):