stoichiograph

Spell words with elemental symbols from the periodic table.
Log | Files | Refs | LICENSE

commit aa2221ff172f2512a8a64f11527e4cea9263c2a3
parent 6fa896ce9ceac64db5b69ec1afef8a2ee3cc9bd8
Author: Amin Mesbah <mesbah.amin@gmail.com>
Date:   Tue, 26 Jan 2016 20:11:49 -0800

find matching chars between word and elemental symbols

Diffstat:
Mspeller.py | 17+++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/speller.py b/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