Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Decision table generator
import csv
import itertools
import sys
def main():
reader = csv.reader(sys.stdin, delimiter='\t')
conditions = {} # ordered dict is assumed
for line in reader:
if not line:
condition, *values = line
conditions[condition] = values
possible_combinations = itertools.product(*conditions.values())
transposed = zip(*possible_combinations)
writer = csv.writer(sys.stdout, delimiter='\t')
for condition, values in zip(conditions, transposed):
writer.writerow((condition, *values))
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment