Re: Combining Two Lists

*To*: mathgroup at smc.vnet.net*Subject*: [mg127028] Re: Combining Two Lists*From*: christopher arthur <chris.arthur1 at gmail.com>*Date*: Mon, 25 Jun 2012 04:02:02 -0400 (EDT)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com*References*: <201206240827.EAA08453@smc.vnet.net>*Reply-to*: chris.arthur1 at gmail.com

look at DataManipulation Hershel Lackey a écrit : > Hi, > > I'm having a little difficulty in combining two lists. These lists > contain individual sets of data and then particular items within the > set. On one list the first column is the set the data is in and the > second column is the particular item, and this is followed by 5 > properties of that item. The second list starts the same, where the > first column is the set the data is in and the second column is the > item, but instead of having the properties listed out in individual > columns the data set repeats itself listing the properties A,B,C,D,E,F > all in the same column. Below is a representative example of the two > list. > > List 1 > Data Set Item # Property 1 Property 2 Property 3 Property 4 Property 5 > Q1 1 6.78 25.61 30.90 48.90 0.61 > Q1 2 12.57 23.44 5.22 37.20 6.90 > Q2 8 18.78 21.17 11.37 2.54 0.82 > Q2 2 34.81 14.87 15.04 36.78 4.54 > Q2 10 22.75 10.34 16.61 23.49 3.86 > Q3 5 47.15 7.23 11.23 40.01 3.53 > Q3 8 28.71 12.41 18.40 49.17 5.99 > > List 2 > > Data Set Item# Property 6 Measure % > Q1 1 A 0 > Q1 1 B 5 > Q1 1 C 15 > Q1 1 D 80 > Q1 1 E 0 > Q1 1 F 0 > Q1 2 A 80 > Q1 2 B 10 > Q1 2 C 10 > Q1 2 D 0 > Q1 2 E 0 > Q1 2 F 0 > Q2 2 A 5 > Q2 2 B 5 > Q2 2 C 0 > Q2 2 D 15 > Q2 2 E 0 > Q2 2 F 0 > Q2 8 A 0 > Q2 8 B 0 > Q2 8 C 65 > Q2 8 D 15 > Q2 8 E 0 > Q2 8 F 20 > Q2 10 A 5 > Q2 10 B 5 > Q2 10 C 85 > Q2 10 D 0 > Q2 10 E 0 > Q2 10 F 0 > Q3 5 A 8 > Q3 5 B 0 > Q3 5 C 85 > Q3 5 D 7 > Q3 5 E 0 > Q3 5 F 0 > Q3 8 A 12 > Q3 8 B 3 > Q3 8 C 60 > Q3 8 D 15 > Q3 8 E 0 > Q3 8 F 0 > > Note that the item # are repeat between different data sets, and data > sets are different sizes. > > What I would like to do is combine the two lists matching the first > two columns, to give groups like {Q1, 1, 6.7, 25.61, 30.90, 48.90, > 0.61,{0,5,15,80,0,0}} for each individual. I have used Cases to > identify matching data sets and item numbers in the two lists. It is > then possible to append the two portions of the list to give part of > the desired data set. However, this was laborious in typing in every > data set and then item # into Cases, and impractical for large data > sets. I'm sure there is a way to Map Cases or Select over the list, > and append the appropriate data when data set and item # match, but I > haven't figured out how to do that. Also it seems possible to use an > if then statement; that if the data set and item # match then append, > else move through the list. However, I haven't figured out how to > code for this either. I appreciate any help. > > Thanks, > > Hershel > > > L

**References**:**Combining Two Lists***From:*Hershel Lackey <hhl089827@gmail.com>