Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
find matching chars between word and elemental symbols
  • Loading branch information
mesbahamin committed Jan 27, 2016
1 parent 6fa896c commit aa2221f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions speller.py
@@ -1,18 +1,27 @@
import csv

def main():
symbols = get_symbols('elements.csv')
print(symbols)
symbols = get_csv_data('elements.csv', 1)
test_word = "Osiris"
print(find_matches(test_word, symbols))

def find_matches(word, symbols):
matches = []

def get_symbols(file_name):
for char in word:
single = char
matches += (x for x in symbols if x == char)

return matches

def get_csv_data(file_name, column):
symbols = []

with open(file_name) as infile:
csv_reader = csv.reader(infile, skipinitialspace=True, delimiter=',')
next(csv_reader, None)
for row in csv_reader:
symbols.append(row[1])
symbols.append(row[column])

return symbols

Expand Down

0 comments on commit aa2221f

Please sign in to comment.