Search code examples
matrixodbctcltdbc

Create Matrix from tdbc::odbc $resultset allrows -as lists


I have a result set that I am returning from a result set. I am wanting to turn that into a matrix object to perform in memory lookups on the data. I have never used Matrix and am stuck on getting it to work. Can anyone provide an example?


Solution

  • As far as I can see, the trip through CSV can be avoided by using the matrix's add row method directly.

    ::struct::matrix Mtrx
    Mtrx add columns [llength [$SQLResultSet columns]]
    while {[$SQLResultSet nextlist Return_Row]} {
        Mtrx add row $Return_Row
    }