Skip to main content
deleted 2 characters in body
Source Link

The new JoinAcross essentially gives you a SQL join if you convert the lists to Key-> Value pairs.

  lists = {list1, list2, list3};

  kys = Map[StringReplace[#, {__ ~~ "Col1" -> "KeyCol"}] &, 
  Table[StringJoin["Lst", ToString@iLst, "Col", ToString@kCol], {iLst,
     Length@lists}, {jRow, Length@lists[[iLst]]}, {kCol, 
    Length@lists[[iLst, jRow]]}], {2}];

  kv = Map[Association, 
   Table[kys[[iLst, jRow, kCol]] -> lists[[iLst, jRow, kCol]], {iLst, 
     Length@lists}, {jRow, Length@lists[[iLst]]}, {kCol, 
     Length@lists[[iLst, jRow]]}], {2}];

  mkv = JoinAcross[
  JoinAcross[kv[[1]], kv[[2]], Key[keys[[1Key[kys[[1, 1, 1]]], "Left"], kv[[3]],
   Key[keys[[1Key[kys[[1, 1, 1]]], "Left"];

 merged = SortBy[Values[Normal[mkv]], #[[1]] &];

The new JoinAcross essentially gives you a SQL join if you convert the lists to Key-> Value pairs.

  lists = {list1, list2, list3};

  kys = Map[StringReplace[#, {__ ~~ "Col1" -> "KeyCol"}] &, 
  Table[StringJoin["Lst", ToString@iLst, "Col", ToString@kCol], {iLst,
     Length@lists}, {jRow, Length@lists[[iLst]]}, {kCol, 
    Length@lists[[iLst, jRow]]}], {2}];

  kv = Map[Association, 
   Table[kys[[iLst, jRow, kCol]] -> lists[[iLst, jRow, kCol]], {iLst, 
     Length@lists}, {jRow, Length@lists[[iLst]]}, {kCol, 
     Length@lists[[iLst, jRow]]}], {2}];

  mkv = JoinAcross[
  JoinAcross[kv[[1]], kv[[2]], Key[keys[[1, 1, 1]]], "Left"], kv[[3]],
   Key[keys[[1, 1, 1]]], "Left"];

 merged = SortBy[Values[Normal[mkv]], #[[1]] &];

The new JoinAcross essentially gives you a SQL join if you convert the lists to Key-> Value pairs.

  lists = {list1, list2, list3};

  kys = Map[StringReplace[#, {__ ~~ "Col1" -> "KeyCol"}] &, 
  Table[StringJoin["Lst", ToString@iLst, "Col", ToString@kCol], {iLst,
     Length@lists}, {jRow, Length@lists[[iLst]]}, {kCol, 
    Length@lists[[iLst, jRow]]}], {2}];

  kv = Map[Association, 
   Table[kys[[iLst, jRow, kCol]] -> lists[[iLst, jRow, kCol]], {iLst, 
     Length@lists}, {jRow, Length@lists[[iLst]]}, {kCol, 
     Length@lists[[iLst, jRow]]}], {2}];

  mkv = JoinAcross[
  JoinAcross[kv[[1]], kv[[2]], Key[kys[[1, 1, 1]]], "Left"], kv[[3]],
   Key[kys[[1, 1, 1]]], "Left"];

 merged = SortBy[Values[Normal[mkv]], #[[1]] &];
added 53 characters in body
Source Link

The new JoinAcross essentially gives you a SQL join if you convert the lists to Key-> Value pairs.

  lists = {list1, list2, list3};

  kys = Map[StringReplace[#, {__ ~~ "Col1" -> "KeyCol"}] &, 
  Table[StringJoin["Lst", ToString@iLst, "Col", ToString@kCol], {iLst,
     Length@lists}, {jRow, Length@lists[[iLst]]}, {kCol, 
    Length@lists[[iLst, jRow]]}], {2}];

  kv = Map[Association, 
   Table[kys[[iLst, jRow, kCol]] -> lists[[iLst, jRow, kCol]], {iLst, 
     Length@lists}, {jRow, Length@lists[[iLst]]}, {kCol, 
     Length@lists[[iLst, jRow]]}], {2}];

  mergedmkv = JoinAcross[
  JoinAcross[kv[[1]], kv[[2]], Key[keys[[1, 1, 1]]], "Left"], kv[[3]],
   Key[keys[[1, 1, 1]]], "Left"];

 merged = SortBy[Values[Normal[mkv]], #[[1]] &];

The new JoinAcross essentially gives you a SQL join if you convert the lists to Key-> Value pairs.

  lists = {list1, list2, list3};

  kys = Map[StringReplace[#, {__ ~~ "Col1" -> "KeyCol"}] &, 
  Table[StringJoin["Lst", ToString@iLst, "Col", ToString@kCol], {iLst,
     Length@lists}, {jRow, Length@lists[[iLst]]}, {kCol, 
    Length@lists[[iLst, jRow]]}], {2}];

  kv = Map[Association, 
   Table[kys[[iLst, jRow, kCol]] -> lists[[iLst, jRow, kCol]], {iLst, 
     Length@lists}, {jRow, Length@lists[[iLst]]}, {kCol, 
     Length@lists[[iLst, jRow]]}], {2}];

  merged = JoinAcross[
  JoinAcross[kv[[1]], kv[[2]], Key[keys[[1, 1, 1]]], "Left"], kv[[3]],
   Key[keys[[1, 1, 1]]], "Left"];

The new JoinAcross essentially gives you a SQL join if you convert the lists to Key-> Value pairs.

  lists = {list1, list2, list3};

  kys = Map[StringReplace[#, {__ ~~ "Col1" -> "KeyCol"}] &, 
  Table[StringJoin["Lst", ToString@iLst, "Col", ToString@kCol], {iLst,
     Length@lists}, {jRow, Length@lists[[iLst]]}, {kCol, 
    Length@lists[[iLst, jRow]]}], {2}];

  kv = Map[Association, 
   Table[kys[[iLst, jRow, kCol]] -> lists[[iLst, jRow, kCol]], {iLst, 
     Length@lists}, {jRow, Length@lists[[iLst]]}, {kCol, 
     Length@lists[[iLst, jRow]]}], {2}];

  mkv = JoinAcross[
  JoinAcross[kv[[1]], kv[[2]], Key[keys[[1, 1, 1]]], "Left"], kv[[3]],
   Key[keys[[1, 1, 1]]], "Left"];

 merged = SortBy[Values[Normal[mkv]], #[[1]] &];
added 62 characters in body
Source Link
RunnyKine
  • 33.3k
  • 3
  • 110
  • 176

The new JoinAcrossJoinAcross essentially gives you a SQL join if you convert the lists to Key-> Value pairs.

lists = {list1, list2, list3};

kys = Map[StringReplace[#, {__ ~~ "Col1" -> "KeyCol"}] &, Table[StringJoin["Lst", ToString@iLst, "Col", ToString@kCol], {iLst, Length@lists}, {jRow, Length@lists[[iLst]]}, {kCol, Length@lists[[iLst, jRow]]}], {2}];

kv = Map[Association, Table[kys[[iLst, jRow, kCol]] -> lists[[iLst, jRow, kCol]], {iLst, Length@lists}, {jRow, Length@lists[[iLst]]}, {kCol, Length@lists[[iLst, jRow]]}], {2}];

merged = JoinAcross[ JoinAcross[kv[[1]], kv[[2]], Key[keys[[1, 1, 1]]], "Left"], kv[[3]], Key[keys[[1, 1, 1]]], "Left"];

  lists = {list1, list2, list3};

  kys = Map[StringReplace[#, {__ ~~ "Col1" -> "KeyCol"}] &, 
  Table[StringJoin["Lst", ToString@iLst, "Col", ToString@kCol], {iLst,
     Length@lists}, {jRow, Length@lists[[iLst]]}, {kCol, 
    Length@lists[[iLst, jRow]]}], {2}];

  kv = Map[Association, 
   Table[kys[[iLst, jRow, kCol]] -> lists[[iLst, jRow, kCol]], {iLst, 
     Length@lists}, {jRow, Length@lists[[iLst]]}, {kCol, 
     Length@lists[[iLst, jRow]]}], {2}];

  merged = JoinAcross[
  JoinAcross[kv[[1]], kv[[2]], Key[keys[[1, 1, 1]]], "Left"], kv[[3]],
   Key[keys[[1, 1, 1]]], "Left"];

The new JoinAcross essentially gives you a SQL join if you convert the lists to Key-> Value pairs.

lists = {list1, list2, list3};

kys = Map[StringReplace[#, {__ ~~ "Col1" -> "KeyCol"}] &, Table[StringJoin["Lst", ToString@iLst, "Col", ToString@kCol], {iLst, Length@lists}, {jRow, Length@lists[[iLst]]}, {kCol, Length@lists[[iLst, jRow]]}], {2}];

kv = Map[Association, Table[kys[[iLst, jRow, kCol]] -> lists[[iLst, jRow, kCol]], {iLst, Length@lists}, {jRow, Length@lists[[iLst]]}, {kCol, Length@lists[[iLst, jRow]]}], {2}];

merged = JoinAcross[ JoinAcross[kv[[1]], kv[[2]], Key[keys[[1, 1, 1]]], "Left"], kv[[3]], Key[keys[[1, 1, 1]]], "Left"];

The new JoinAcross essentially gives you a SQL join if you convert the lists to Key-> Value pairs.

  lists = {list1, list2, list3};

  kys = Map[StringReplace[#, {__ ~~ "Col1" -> "KeyCol"}] &, 
  Table[StringJoin["Lst", ToString@iLst, "Col", ToString@kCol], {iLst,
     Length@lists}, {jRow, Length@lists[[iLst]]}, {kCol, 
    Length@lists[[iLst, jRow]]}], {2}];

  kv = Map[Association, 
   Table[kys[[iLst, jRow, kCol]] -> lists[[iLst, jRow, kCol]], {iLst, 
     Length@lists}, {jRow, Length@lists[[iLst]]}, {kCol, 
     Length@lists[[iLst, jRow]]}], {2}];

  merged = JoinAcross[
  JoinAcross[kv[[1]], kv[[2]], Key[keys[[1, 1, 1]]], "Left"], kv[[3]],
   Key[keys[[1, 1, 1]]], "Left"];
Source Link
Loading