Re: [U2] Inverting/Pivoting a table
David, How many rows are there in your source flat file? If you found an intrinsic function to do what you are after, what next? What would you do with the resulting in-memory array? Knowing the size of the data set, and the end use, can impact the best solution to your problem at hand, and at the moment I don't know WHY you think you need this Ross Ferris Stamina Software Visage Better by Design! -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Dave Laansma Sent: Tuesday, 11 September 2012 6:32 AM To: U2 Users List Subject: Re: [U2] Inverting/Pivoting a table :-) 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: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of George Gallen Sent: Monday, September 10, 2012 4:31 PM To: U2 Users List Subject: Re: [U2] Inverting/Pivoting a table Why is the Kink's song Lola suddenly playing in my mind! -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson Sent: Monday, September 10, 2012 4:21 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] Inverting/Pivoting a table Columns become rows Rows become columns ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] Inverting/Pivoting a table
Not a function, but there are some subroutines that flip posted on PickWiki: http://www.pickwiki.com/cgi-bin/wiki.pl?Row2Col AND http://www.pickwiki.com/cgi-bin/wiki.pl?Row2Col_II rex ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] Inverting/Pivoting a table
SPLICE ... now THAT'S a cool little tool! I'll have to do some testing with null attributes and values, but this just may work! Thank you Rex and Stuart! Sincerely, David Laansma -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Rex Gozar Sent: Tuesday, September 11, 2012 1:08 PM To: U2 Users List Subject: Re: [U2] Inverting/Pivoting a table Not a function, but there are some subroutines that flip posted on PickWiki: http://www.pickwiki.com/cgi-bin/wiki.pl?Row2Col AND http://www.pickwiki.com/cgi-bin/wiki.pl?Row2Col_II rex ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] Inverting/Pivoting a table
Just a little curiosity... ADP, in their flavor of Reality, has a user exit that did exactly this kind of transformation. Was kind of handy. Perry -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Dave Laansma Sent: Tuesday, September 11, 2012 11:49 AM To: U2 Users List Subject: Re: [U2] Inverting/Pivoting a table SPLICE ... now THAT'S a cool little tool! I'll have to do some testing with null attributes and values, but this just may work! Thank you Rex and Stuart! Sincerely, David Laansma -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Rex Gozar Sent: Tuesday, September 11, 2012 1:08 PM To: U2 Users List Subject: Re: [U2] Inverting/Pivoting a table Not a function, but there are some subroutines that flip posted on PickWiki: http://www.pickwiki.com/cgi-bin/wiki.pl?Row2Col AND http://www.pickwiki.com/cgi-bin/wiki.pl?Row2Col_II rex ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. ZirMed, Inc. has strict policies regarding the content of e-mail communications, specifically Protected Health Information, any communications containing such material will be returned to the originating party with such advisement noted. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
[U2] Inverting/Pivoting a table
I get flat files that I'd like to 'flip' to accommodate the multi-value database. For example, given this table: 123456vmDAVID JONESvm1234 MAIN ST.vmANYWHEREvmMIvm12345am 654321vmJOHN SMITHvm4321 MAIN ST.vmANYWHEREvmMIvm12345 Is there a function that will change it to: 123456vm654321am DAVID JONESvmJOHN SMITHam 1234 MAIN ST.vm4321 MAIN ST.am ANYWHEREvmANYWHEREam MIvmMIam 12345vm12345 Right now I use these nested loops, which tend to take a while depending on the size of TABLE: NEW.TABLE = FOR A1 = 1 TO DCOUNT(TABLE,@AM) FOR V1 = 1 TO DCOUNT(TABLEA1,@VM) NEW.TABLEV1,A1 = TABLEA1,V1 NEXT V1 NEXT A1 TABLE = NEW.TABLE Sincerely, David Laansma ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
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 ... 123456vmDAVID JONESvm1234 MAIN ST.vmANYWHEREvmMIvm12345am 654321vmJOHN SMITHvm4321 MAIN ST.vmANYWHEREvmMIvm12345 Is there a function that will change it to: 123456vm654321am DAVID JONESvmJOHN SMITHam 1234 MAIN ST.vm4321 MAIN ST.am ANYWHEREvmANYWHEREam MIvmMIam 12345vm12345 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(TABLEA1,@VM) NEW.TABLEV1,A1 = TABLEA1,V1 NEXT V1 NEXT A1 TABLE = NEW.TABLE Sincerely, David Laansma Cheers, Wol ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] Inverting/Pivoting a table
REFOMAT -Original Message- From: Wols Lists antli...@youngman.org.uk To: u2-users u2-users@listserver.u2ug.org 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 ... 123456vmDAVID JONESvm1234 MAIN ST.vmANYWHEREvmMIvm12345am 654321vmJOHN SMITHvm4321 MAIN ST.vmANYWHEREvmMIvm12345 Is there a function that will change it to: 123456vm654321am DAVID JONESvmJOHN SMITHam 1234 MAIN ST.vm4321 MAIN ST.am ANYWHEREvmANYWHEREam MIvmMIam 12345vm12345 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(TABLEA1,@VM) NEW.TABLEV1,A1 = TABLEA1,V1 NEXT V1 NEXT A1 TABLE = NEW.TABLE Sincerely, David Laansma Cheers, Wol ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
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: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson Sent: Monday, September 10, 2012 2:20 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] Inverting/Pivoting a table REFOMAT -Original Message- From: Wols Lists antli...@youngman.org.uk To: u2-users u2-users@listserver.u2ug.org 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 ... 123456vmDAVID JONESvm1234 MAIN ST.vmANYWHEREvmMIvm12345am 654321vmJOHN SMITHvm4321 MAIN ST.vmANYWHEREvmMIvm12345 Is there a function that will change it to: 123456vm654321am DAVID JONESvmJOHN SMITHam 1234 MAIN ST.vm4321 MAIN ST.am ANYWHEREvmANYWHEREam MIvmMIam 12345vm12345 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(TABLEA1,@VM) NEW.TABLEV1,A1 = TABLEA1,V1 NEXT V1 NEXT A1 TABLE = NEW.TABLE Sincerely, David Laansma Cheers, Wol ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] Inverting/Pivoting a table
REFORMAT is a TCL command. -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] 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: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson Sent: Monday, September 10, 2012 2:20 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] Inverting/Pivoting a table REFOMAT -Original Message- From: Wols Lists antli...@youngman.org.uk To: u2-users u2-users@listserver.u2ug.org 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 ... 123456vmDAVID JONESvm1234 MAIN ST.vmANYWHEREvmMIvm12345am 654321vmJOHN SMITHvm4321 MAIN ST.vmANYWHEREvmMIvm12345 Is there a function that will change it to: 123456vm654321am DAVID JONESvmJOHN SMITHam 1234 MAIN ST.vm4321 MAIN ST.am ANYWHEREvmANYWHEREam MIvmMIam 12345vm12345 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(TABLEA1,@VM) NEW.TABLEV1,A1 = TABLEA1,V1 NEXT V1 NEXT A1 TABLE = NEW.TABLE Sincerely, David Laansma Cheers, Wol ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
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: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] 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: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] 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: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson Sent: Monday, September 10, 2012 2:20 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] Inverting/Pivoting a table REFOMAT -Original Message- From: Wols Lists antli...@youngman.org.uk To: u2-users u2-users@listserver.u2ug.org 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 ... 123456vmDAVID JONESvm1234 MAIN ST.vmANYWHEREvmMIvm12345am 654321vmJOHN SMITHvm4321 MAIN ST.vmANYWHEREvmMIvm12345 Is there a function that will change it to: 123456vm654321am DAVID JONESvmJOHN SMITHam 1234 MAIN ST.vm4321 MAIN ST.am ANYWHEREvmANYWHEREam MIvmMIam 12345vm12345 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(TABLEA1,@VM) NEW.TABLEV1,A1 = TABLEA1,V1 NEXT V1 NEXT A1 TABLE = NEW.TABLE Sincerely, David Laansma Cheers, Wol ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] Inverting/Pivoting a table
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 dlaan...@hubbardsupply.com To: U2 Users List u2-users@listserver.u2ug.org 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: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] 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: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] 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: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson Sent: Monday, September 10, 2012 2:20 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] Inverting/Pivoting a table REFOMAT -Original Message- From: Wols Lists antli...@youngman.org.uk To: u2-users u2-users@listserver.u2ug.org 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 ... 123456vmDAVID JONESvm1234 MAIN ST.vmANYWHEREvmMIvm12345am 654321vmJOHN SMITHvm4321 MAIN ST.vmANYWHEREvmMIvm12345 Is there a function that will change it to: 123456vm654321am DAVID JONESvmJOHN SMITHam 1234 MAIN ST.vm4321 MAIN ST.am ANYWHEREvmANYWHEREam MIvmMIam 12345vm12345 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(TABLEA1,@VM) NEW.TABLEV1,A1 = TABLEA1,V1 NEXT V1 NEXT A1 TABLE = NEW.TABLE Sincerely, David Laansma Cheers, Wol ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] Inverting/Pivoting a table
Excerpt from page 1-161 of the UniQuery Commands Reference available at http://www.rocketsoftware.com/u2/products/unidata/resources/manuals/unid ata-7.3-documentation/uniquery-commands-reference/view REFORMAT Syntax REFORMAT filename attributes [selection_criteria] Description The UniQuery REFORMAT command copies record attributes you specify from one data file to another data file. The destination file must already exist. REFORMAT uses the first attribute named in the UniQuery statement as the record ID in the destination file. The remaining attributes in the UniQuery statement become record attributes in the destination file. UniQuery prompts for the name of the destination file after you enter the REFORMAT command. Sincerely, David Laansma -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson Sent: Monday, September 10, 2012 4:02 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] Inverting/Pivoting a table 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 dlaan...@hubbardsupply.com To: U2 Users List u2-users@listserver.u2ug.org 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: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] 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: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] 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: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson Sent: Monday, September 10, 2012 2:20 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] Inverting/Pivoting a table REFOMAT -Original Message- From: Wols Lists antli...@youngman.org.uk To: u2-users u2-users@listserver.u2ug.org 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 ... 123456vmDAVID JONESvm1234 MAIN ST.vmANYWHEREvmMIvm12345am 654321vmJOHN SMITHvm4321 MAIN ST.vmANYWHEREvmMIvm12345 Is there a function that will change it to: 123456vm654321am DAVID JONESvmJOHN SMITHam 1234 MAIN ST.vm4321 MAIN ST.am ANYWHEREvmANYWHEREam MIvmMIam 12345vm12345 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(TABLEA1,@VM) NEW.TABLEV1,A1 = TABLEA1,V1 NEXT V1 NEXT A1 TABLE = NEW.TABLE Sincerely, David Laansma Cheers, Wol ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing
Re: [U2] Inverting/Pivoting a table
Columns become rows Rows become columns We call them attributes and item-ids, but it's the same difference -Original Message- From: Dave Laansma dlaan...@hubbardsupply.com To: U2 Users List u2-users@listserver.u2ug.org Sent: Mon, Sep 10, 2012 1:12 pm Subject: Re: [U2] Inverting/Pivoting a table Excerpt from page 1-161 of the UniQuery Commands Reference available at http://www.rocketsoftware.com/u2/products/unidata/resources/manuals/unid ata-7.3-documentation/uniquery-commands-reference/view REFORMAT Syntax REFORMAT filename attributes [selection_criteria] Description The UniQuery REFORMAT command copies record attributes you specify from one data file to another data file. The destination file must already exist. REFORMAT uses the first attribute named in the UniQuery statement as the record ID in the destination file. The remaining attributes in the UniQuery statement become record attributes in the destination file. UniQuery prompts for the name of the destination file after you enter the REFORMAT command. Sincerely, David Laansma -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson Sent: Monday, September 10, 2012 4:02 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] Inverting/Pivoting a table 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 dlaan...@hubbardsupply.com To: U2 Users List u2-users@listserver.u2ug.org 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: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] 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: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] 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: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson Sent: Monday, September 10, 2012 2:20 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] Inverting/Pivoting a table REFOMAT -Original Message- From: Wols Lists antli...@youngman.org.uk To: u2-users u2-users@listserver.u2ug.org 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 ... 123456vmDAVID JONESvm1234 MAIN ST.vmANYWHEREvmMIvm12345am 654321vmJOHN SMITHvm4321 MAIN ST.vmANYWHEREvmMIvm12345 Is there a function that will change it to: 123456vm654321am DAVID JONESvmJOHN SMITHam 1234 MAIN ST.vm4321 MAIN ST.am ANYWHEREvmANYWHEREam MIvmMIam 12345vm12345 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(TABLEA1,@VM) NEW.TABLEV1,A1 = TABLEA1,V1 NEXT V1 NEXT A1 TABLE = NEW.TABLE Sincerely, David Laansma Cheers, Wol ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users
Re: [U2] Inverting/Pivoting a table
Why is the Kink's song Lola suddenly playing in my mind! -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson Sent: Monday, September 10, 2012 4:21 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] Inverting/Pivoting a table Columns become rows Rows become columns ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] Inverting/Pivoting a table
:-) 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: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of George Gallen Sent: Monday, September 10, 2012 4:31 PM To: U2 Users List Subject: Re: [U2] Inverting/Pivoting a table Why is the Kink's song Lola suddenly playing in my mind! -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson Sent: Monday, September 10, 2012 4:21 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] Inverting/Pivoting a table Columns become rows Rows become columns ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] Inverting/Pivoting a table
* OPT 1: a little quicker than nested for..next (depending on how many) xx = dcount(array1,@vm) for x = 1 to xx newarr-1 = array1,x:@vm:array2,x next x OR * OPT 2: the fastest...(cos it maintains a file pos pointer) arr1 = array1 arr2 = array2 more = 1 loop remove val1 from arr1 setting more remove val2 from arr2 setting junk newarr-1 = val1:@vm:val2 while more repeat OR OPT 3: the neatest.. (ie least maintainable) arr1 = array1 arr2 = array2 arr1 = change(arr1,@vm, '+':@vm) : '+' newarr = cats(arr1,arr2) convert '+' to @vm in newarr (use whatever char you wont have in your data) On 10 September 2012 23:39, Dave Laansma dlaan...@hubbardsupply.com wrote: I get flat files that I'd like to 'flip' to accommodate the multi-value database. For example, given this table: 123456vmDAVID JONESvm1234 MAIN ST.vmANYWHEREvmMIvm12345am 654321vmJOHN SMITHvm4321 MAIN ST.vmANYWHEREvmMIvm12345 Is there a function that will change it to: 123456vm654321am DAVID JONESvmJOHN SMITHam 1234 MAIN ST.vm4321 MAIN ST.am ANYWHEREvmANYWHEREam MIvmMIam 12345vm12345 Right now I use these nested loops, which tend to take a while depending on the size of TABLE: NEW.TABLE = FOR A1 = 1 TO DCOUNT(TABLE,@AM) FOR V1 = 1 TO DCOUNT(TABLEA1,@VM) NEW.TABLEV1,A1 = TABLEA1,V1 NEXT V1 NEXT A1 TABLE = NEW.TABLE Sincerely, David Laansma ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users