Skip to content

Instantly share code, notes, and snippets.



Created Apr 13, 2017
What would you like to do?
import csv
ral_for_sale = [ "RAL7035", "RAL7038", "RAL7036", "RAL7030", "RAL7037", "RAL7015", "RAL9005", "RAL8017", "RAL1016", "RAL1021", "RAL1004", "RAL2008", "RAL3017", "RAL3000", "RAL3003", "RAL3005", "RAL6027", "RAL6034", "RAL6019", "RAL6033", "RAL6020", "RAL6012", "RAL6005", "RAL5014", "RAL5022", "RAL5024", "RAL5002", "RAL5010", "RAL9001", "RAL1013", "RAL1015", "RAL9002"]
with open("ral.csv", "r") as csv_file:
ral_reader = csv.reader(csv_file)
rals = [(row[0].replace(" ", ""), row[2]) for row in ral_reader]
# filter out the ones that we have
available = {x[0]: x[1] for x in filter(lambda x: x[0] in ral_for_sale, rals)}
# now write html file that has the colours we want
def html(name, colour):
return """
<div style="width: 200px; height: 80px;float:right; margin-bottom: 40px;">
<div style="width: 200px; height: 100%; background-color: {0}"></div>
""".format(colour, name)
all_html = [html(name, colour) for name, colour in available.items()]
with open('ral.html', 'w') as rf:
for some_html in all_html:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.