def writeToFile(): with open('vocab.csv', 'w', newline='', encoding='utf-8') as csvfile: writer = csv.writer(csvfile, delimiter='\t') for word in Word.getAll(): if not word.isDupe(): writer.writerow(word.toArray()) csvfile.close()
if not word.isDupe(): writer.writerow(word.toArray()) csvfile.close() originalTotalCount = Word.totalCount() originalDupeCount = Word.dupeCount() originalRelationshipCount = Word.relationshipCount() for (path, dirs, files) in os.walk('./vocab'): book = path.split('./vocab')[1][1:] for filename in files: filepath = os.path.join(path, filename) chapter = str(int(filename.split('.')[0])) section = filename.split('.')[1] populate(filepath, book, chapter, section) print("Database synced") print(str(Word.totalCount() - originalTotalCount) + " new records, " + str(Word.totalCount()) + " total records") i=1 for word in Word.getAll(): resolveDuplicates(word, i) i += 1 print("Duplicates resolved") print(str(Word.totalCount() - originalTotalCount) + " new words, " + str(Word.dupeCount() - originalDupeCount) + " new dupes, " + str(Word.relationshipCount() - originalRelationshipCount) + " new relationships") print(str(Word.totalCount()) + " total words, " + str(Word.totalCount() - Word.dupeCount()) + " total originals, " + str(Word.dupeCount()) + " total dupes, " + str(Word.relationshipCount()) + " total relationships") writeToFile(); print("vocab.csv created")