Page 1 of 1

Variable Length Vector to Delimited String Array

Posted: Tue Feb 05, 2013 12:15 pm
by rameshrr3
I have a data in which one column is a vector
data looks like this
[^X 2 4 22 22 19 8 ]
^X is the vector length prefix ( 1 bytes)
the rest are elements of the vector.

Is there any way i can convert the output to a delimited string array ?
Output should be like
'2'|'4'|'22'|'22'|'19'|'8'|

I could do a column export with appropriate delimiter & quote char and use modify stage to remove the 1 byte prefix using spec : substring[1,x](colname), and remove the vector definition from the output column using edit column metadata - but i think its not an elegant way of doing so - even though it seems to achieve the desired result.

Posted: Tue Feb 05, 2013 3:23 pm
by ray.wurlod
Doesn't seem inelegant to me. You could investigate the Split Vector stage.

Posted: Thu Feb 07, 2013 12:05 pm
by rameshrr3
Yes , I countinued with the 'workaround' I have ( The modify stage trimming made it look inelegant to me ) . But i think the variable length vector can be padded ( or defined in column metadata) to a fixed length that will be all inclusive . The split vector stage will require a fixed length vector input to work. The trick with split vector stage is to name the split columns the same name as the vector input column , appended with an index number staring with 0 to n-1 ( For a fixed vector of n elements)