# Combining 2 Files . 1 line to many lines

2 Files A and B. A has 2593 lines and B has 18900000. I would like to Take A[i] and associate(added to the same line) it with 720 lines of B. Then A[1+1] associate it with the next 720 lines in B. So in the end A[2593] would be associated with the last 720 lines of file B.

I can do it with for loops, but would like a more elegant and effiecient way.

A={{1,2,3},{4,2,5},{9,11,3}...{5,2,8}} B= Same format

Any assistance or documentation would be appreciated.

Thank You Michel

• does MapThread[Join, {A, Flatten /@ Partition[B, 720]}] work? – kglr Aug 23 at 0:38
• is Dimensions@B {18900000,3}? – kglr Aug 23 at 1:31
• That is not the form I am looking for, The result would be as: A[1]->B[1] A[1]->B[2] . . . . A[1]->B[720] A[2]->B[721] . . . . A[2]->B[1440] A[3]->B[1441] . . . . A[2593]->B[1866960] Thank You Michel – Michel Mesedahl Aug 23 at 1:35
• how about Join@@MapThread[Thread[Rule@##, List, {2}] &, {A, Partition[B, 720]}]? – kglr Aug 23 at 1:38
• It is {1866960,6} I am attempting to get it into a form for a neural Network. – Michel Mesedahl Aug 23 at 1:42

Join @@ MapThread[Thread[Rule @ ##, List, {2}] &,

• @MichelMesedahl, does Join @@ MapThread[Thread[Rule @ ##, List, {2}] &, {A, Partition[B[[;; 720 Length @ A]], 720]}] work? – kglr Aug 25 at 16:19