Created
January 8, 2021 05:17
-
-
Save codingfoo/44e9aa604913bced578717fa3254bb25 to your computer and use it in GitHub Desktop.
Generate Reading list from a csv list of recomendations.
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
import csv | |
HARD_MODE = 2 | |
NORMAL_MODE = 3 | |
recs_column = HARD_MODE | |
name_column = 0 | |
from constraint import * | |
problem = Problem() | |
with open('recomendations.csv') as csv_file: | |
csv_reader = csv.reader(csv_file, delimiter=',') | |
line_count = 0 | |
for row in csv_reader: | |
if line_count == 0: | |
line_count += 1 | |
continue | |
if line_count > 5: | |
break | |
square_name = row[name_column] | |
recomendations = row[recs_column].split(',') | |
print(square_name, recomendations) | |
problem.addVariable(square_name, recomendations) | |
line_count += 1 | |
print(f'Processed {line_count} lines.') | |
problem.addConstraint(AllDifferentConstraint()) | |
print(problem.getSolutions()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment