Last active
October 4, 2018 05:31
-
-
Save jice-lavocat/1b77096760c90ad0e7ea67349029ee93 to your computer and use it in GitHub Desktop.
Create all possible combinations from several list to CSV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This allowed me to create easily multiple combinations for an Airtable base.