Skip to content

Instantly share code, notes, and snippets.

@socksy
Created February 9, 2013 04:14
Show Gist options
  • Save socksy/4743803 to your computer and use it in GitHub Desktop.
Save socksy/4743803 to your computer and use it in GitHub Desktop.
Finding out the duplicate colour names
>>>> import csv
>>>> f = open("colors.txt")
>>>> ramalan = csv.reader(f, delimiter=',')
>>>> colours = []
>>>> for x in ramalan:
... colours.append(x)
...
# Here we get rid of some malformed entries
>>>> colours = [c for c in colours if len(c) == 2]
# Now we look for duplicates by keeping track of what's been seen
>>>> seen = []
>>>> for c in colours:
... for s in seen:
... if c[0]==s[0] and c[1]!=s[1]: # hex same, name different
... print c[1] + " with " + s[1] + " (" + c[0] + ")"
... if c not in seen:
... seen.append(c)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment