Guest User

Untitled

a guest
Nov 13th, 2026
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. blocks = []
  2. current_place = None
  3. entries = []
  4.  
  5. with open("R:\\input.txt", "r", encoding="utf-8") as input_file:
  6. for line in input_file:
  7. line = line.strip()
  8. if not line:
  9. continue
  10.  
  11. if "\t" not in line: # A place heading
  12. if current_place is not None:
  13. blocks.append((current_place, entries))
  14. current_place = line
  15. entries = []
  16. else: # A candidate entry
  17. entries.append(line)
  18.  
  19. if current_place is not None:
  20. blocks.append((current_place, entries))
  21.  
  22. count = 0
  23. with open("R:\\output.txt", "w", encoding="utf-8") as output_file:
  24. for place, entries in blocks:
  25. if len(entries) == 1:
  26. count += 1
  27. output_file.write(f"{count}. {place}\n")
Advertisement
Add Comment
Please, Sign In to add comment