EXECUTE "REFORMAT" it doesn't copy, it changes the format as well in other words, it pivots, as you asked
-----Original Message----- From: Dave Laansma <[email protected]> To: U2 Users List <[email protected]> Sent: Mon, Sep 10, 2012 12:59 pm Subject: Re: [U2] Inverting/Pivoting a table REFORMAT appears to be a UniQuery command and appears to be used to copy records from one file to another. I'm looking for this type of functionality in a UniBasic program. Sincerely, David Laansma -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Robert Houben Sent: Monday, September 10, 2012 3:41 PM To: U2 Users List Subject: Re: [U2] Inverting/Pivoting a table REFORMAT is a TCL command. -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Dave Laansma Sent: September-10-12 12:39 PM To: U2 Users List Subject: Re: [U2] Inverting/Pivoting a table REFORMAT perhaps? I am find no reference to a Unibasic command/statement REFORMAT. Sincerely, David Laansma IT Manager Hubbard Supply Co. Direct: 810-342-7143 Office: 810-234-8681 Fax: 810-234-6142 www.hubbardsupply.com "Delivering Products, Services and Innovative Solutions" -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Wjhonson Sent: Monday, September 10, 2012 2:20 PM To: [email protected] Subject: Re: [U2] Inverting/Pivoting a table 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 _______________________________________________ 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 _______________________________________________ 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
