Converting multiple 1D attributes to a 2D matrix


I have the following array named “tabular”, created in SciDB:
tabular<attribute_0:double, another_attribute_1:double, yet_another_attribute:double>[row_id=0:9999,10000,0]
Think of it as a spreadsheet with 3 unique column names and 10000 rows, but all attributes (columns) as type double.

How do I convert this to a 2D array with schema: matrixval:double[row_id=0:9999,10000,0, col_id=0:2,3,0] ?

Seems rather inefficient to write “tabular” to a csv file, run CSV2SCIDB and then load the resulting tabular.scidb file back into a 2D array.


Hi Frank,

The query would be something like:

    tabular as A,
    build( <col_id:int64> [i=0:2,3,0], i)
   iif(col_id = 0, attribute_0, iif(col_id = 1, another_attribute_1, yet_another_attribute))
  <val:double>[row_id=0:9999,10000,0, col_id=0:2,3,0]

(Haven’t tried to run it, hoping that I got the parentheses all lined up).
Does that make sense?

  • Alex Poliakov


Alex, thanks for pointing me in the right direction.
I’m getting a “val has incorrect properties” error,
but as they say in text books, “the solution of this problem is trivial and is left as an exercise for the reader”.


Alex, thanks again, your code works correctly.
What I assumed to be double values are actually double NULL DEFAULT null.