REFOMAT


-----Original Message-----
From: Wols Lists <[email protected]>
To: u2-users <[email protected]>
Sent: Mon, Sep 10, 2012 11:07 am
Subject: Re: [U2] Inverting/Pivoting a table


On 10/09/12 14:39, Dave Laansma wrote:
> I get flat files that I'd like to 'flip' to accommodate the multi-value
> database. For example, given this table:
> 
I thought there was a command that would flip a FILE like that. I've
never used it, but I recall a colleague making good use of it ...
>  
> 123456<vm>DAVID JONES<vm>1234 MAIN ST.<vm>ANYWHERE<vm>MI<vm>12345<am>
> 
> 654321<vm>JOHN SMITH<vm>4321 MAIN ST.<vm>ANYWHERE<vm>MI<vm>12345
> 
>  
> 
> Is there a function that will change it to:
> 
>  
> 
> 123456<vm>654321<am>
> 
> DAVID JONES<vm>JOHN SMITH<am>
> 
> 1234 MAIN ST.<vm>4321 MAIN ST.<am>
> 
> ANYWHERE<vm>ANYWHERE<am>
> 
> MI<vm>MI<am>
> 
> 12345<vm>12345
> 
>  
> 
> Right now I use these nested loops, which tend to take a while depending
> on the size of TABLE:
> 
And here you're using dynamic arrays. If you're in PI syntax, do a
DCOUNT to get the number of people, dimension some static arrays, and
dump the data into that. It'll be MUCH faster. You can REMOVE the
elements from the original dynamic array (fast), dump them into your
static array(s) (fast), and MATBUILD your new array (fast).
>  
> 
> NEW.TABLE = ""
> 
>  
> 
> FOR A1 = 1 TO DCOUNT(TABLE,@AM)
> 
>   FOR V1 = 1 TO DCOUNT(TABLE<A1>,@VM)
> 
>     NEW.TABLE<V1,A1> = TABLE<A1,V1>
> 
>   NEXT V1
> 
> NEXT A1
> 
>  
> 
> TABLE = NEW.TABLE
> 
>  
> 
> Sincerely,
> 
> David Laansma
> 
Cheers,
Wol
_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users

 
_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to