Skip to content

Instantly share code, notes, and snippets.

@jice-lavocat
Last active October 4, 2018 05:31
Show Gist options
  • Save jice-lavocat/1b77096760c90ad0e7ea67349029ee93 to your computer and use it in GitHub Desktop.
Save jice-lavocat/1b77096760c90ad0e7ea67349029ee93 to your computer and use it in GitHub Desktop.
Create all possible combinations from several list to CSV
# Based on https://stackoverflow.com/a/798893/2550237
import itertools
import csv
games = ["Angry Birds", "Clash of Clans"]
platforms = ["iOS", "Android"]
dates = ["1/1/2018", "1/2/2018", "1/3/2018", "1/4/2018", "1/5/2018",
"1/6/2018", "1/7/2018", "1/8/2018", "1/9/2018", "1/10/2018",
"1/11/2018", "1/12/2018"]
a = [games, platforms, dates]
all_combination = list(itertools.product(*a))
with open('output.csv', 'wb') as csvfile:
writer = csv.writer(csvfile, delimiter=',',
quotechar='|', quoting=csv.QUOTE_MINIMAL)
for combi in all_combination:
writer.writerow(combi)
@jice-lavocat
Copy link
Author

This allowed me to create easily multiple combinations for an Airtable base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment