Advertisement
tanchukw

Untitled

Sep 14th, 2015
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. import codecs
  2.  
  3. print("Write count of inputed files\n")
  4. count_of_files = int(input())
  5.  
  6. dictionary = []
  7. for i in range(1, count_of_files + 1):
  8.     print("Write path to the " + str(i) + " inputed file\n")
  9.     if i == 1:
  10.         print("Example of path: \"/home/username/folder/example.txt\"\n")
  11.     path = str(input())
  12.     with codecs.open(path, "r", "utf-8") as ifs:
  13.         for line in ifs:
  14.             items = line.split()
  15.             for item in items:
  16.                 if dictionary.count(item) == 0:
  17.                     dictionary.append(item)
  18.  
  19. dictionary.sort()
  20.  
  21. print("Write path to the folder where need to save a dictionary\n")
  22. print("Example of path: \"/home/username/folder/\"\n")
  23. path = str(input())
  24. with codecs.open(path + "dictionary.txt", "w", "utf-8") as ofs:
  25.     for word in dictionary:
  26.         ofs.write("%s\n" % word)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement