11-11-2019 11:57 PM
I'm currently working on a spatial model where I want to extract certain columns of an attribute table and combine them to a text file output with column names and the according values.
Until now I was able to create two matrices: One with the actual values of according columns (integer) and one with the column names (string). I was creating tables seperately and combining them to a matrix with the Resize Matrix operator.
Matrix 1 holding attribute values (integer):
Matrix 2 holding the column names (string):
Is it possible to convert the table/matrix data type from integer to string to combine the two matrices with the Resize Matrix operator?
When writing the two matrices into a report, is it possible to only write the acutal values into the report without matrix size and data type (see screenshot below)?
I'm thankful for any hint
All the best!
Solved! Go to Solution.
11-12-2019 08:41 AM
Not sure about your other questions, but here's how you would convert a Table of numbers (Float, Integer, Binary) into a Table of Strings. I also put operators on to convert that Table to a Matrix (BTW - I never knew that you could have Strings in a Matrix - that's new to me) and write out a Report file:
Here's what happens inside the Iterator:
So, in my simple example I input a Float Table containing three values: 0.0, 2.0 and 5.5. That table can be used to drive an Iterator that operators on each of the three values.
In the Iterator each input Scalar value is converted to IMAGINE.Double in order to remove any "decoration". If the original Table had been integers you would use IMAGINE.Int, etc., instead. The undecorated value is then converted to String and exits the Iterator.
The Iterator thereby builds a List of three Strings. That list could be used directly as a Table of Strings, or here it's fed to a Table to Matrix operator to convert into a Matrix of Strings.
I don't think you could directly do this to a Matrix input. But you could wrap another iterator layer around this and break the Matrix into a List of Tables to be iterated over.
Hope this points you in the right direction.