MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Joining List of Lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg64360] Joining List of Lists
  • From: Benedetto Bongiorno <bbongiorno at attglobal.net>
  • Date: Tue, 14 Feb 2006 01:31:35 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

To All,

In the folowing routine, I am trying to combine two tables of lists of 
lists, that are not of equal size, by
the intersection index of a common column of both tables.
The routine works but it runs for hours. The bottleneck is the join 
routine using For.
How can I use Map or MapThread to speed up the process?

Thank you.

Ben Bongiorno


"Create Index"
"Create an Index of equivalents"

Dimensions[idx]
{175371,4}

Dimensions[data]
{314791,13}

aa = idx[[All,loc02[[1]]]];
bb = data[[All,loc01[[5]]]];
indx = Intersection[aa,bb];

Dimensions[indx]
{16267}

"Select the rows with matching field"

ans01 = Select[idx, MemberQ[indx, #[[loc02[[1]]]]]&];
ans02 = Select[data, MemberQ[indx,#[[loc01[[5]]]]]&];

Dimensions[ans01]
{16267,4}

Dimensions[ans02]
{314791,13}

"Join "

descripData={};

n=Length[ans02]+1;

For[i=1,i<n,i++,
    nn=Length[ans01]+1;
    For[j=1,j<nn,j++,
      If[ans02[[i,loc01[[5]]]]==ans01[[j,loc02[[1]]]],
        AppendTo[descripData,RowJoin[{ans02[[i]]},{ans01[[j]]}]]]]];

Dimensions[descripData]
{314791,1,17}

descripData=Flatten[descripData,1];
Dimensions[descripData]
{314791,17}


  • Prev by Date: Re: Eliminate Complex Roots
  • Next by Date: Re: Eliminate Complex Roots
  • Previous by thread: Re: Using a text editor like interface for Mathematica?
  • Next by thread: Re: Joining List of Lists