{items_text: items ? separate each item with a new line, separate groups of items with '---'}
# Crosscompute
items_text_path = './items.txt'
target_folder = './results/'
from os.path import join
items = items_text_path
items = open(items_text_path, 'r').read()
import re
pattern = re.compile(r'-+')
lists = []
for l in pattern.split(items):
lists.append([x.strip() for x in l.splitlines() if x.strip()])
npairs = len(lists)
from itertools import product, groupby
from operator import itemgetter
from pandas import DataFrame
possible_combinations = sorted(list(product(*lists)), key=itemgetter(0))
lists = groupby(possible_combinations, key=itemgetter(0))
i = 1
paths = []
for k, g in lists:
target_path = join(target_folder, 'combos%d.csv' % i)
paths.append(target_path)
i += 1
df = DataFrame(list(g))
df.to_csv(target_path, index=False)
for i, p in enumerate(paths):
print('combos%d_table_path = %s' % (i, p))