from db import * op = input('op [exp/imp]: ') mode = input('mode [0/1]: ') if mode != '0' and mode != '1': print('Wrong mode, exit...') exit() db = read() if op == 'exp': out_text = '' for i in db[mode]: out_text += i + '\n' with open('out.txt', 'w') as f: f.write(out_text) f.close() print('Exported!') elif op == 'imp': print('Select mode: append/replace') op_mode = input('app/rep (app): ') with open('out.txt', 'r') as f: lines = f.read().split('\n') f.close() words = [] for i in lines: words.append(i) words.remove('') if op_mode == 'app' or op_mode == '': # Add existing words words += db[mode] print('Appending...') elif op_mode == 'rep': print('Replacing...') # Remove duplicates words = list(set(words)) db[mode] = words write(db)