p = import("P.csv"); q = import("Q.csv"); r = import("R.csv"); s = import("S.csv"); t = import("T.csv"); for pr in p { for qr in q { for rr in r { for sr in s { for tr in t { out.add(pr[0], pr[1], pr[2], qr[0], qr[1], qr[2], rr[0], sr[0], tr[0], tr[1], tr[2], tr[3]); } } } } }