Advertisement
wowonline

Untitled

Apr 14th, 2022
894
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. lines = []
  3.  
  4. with open('the_calls.txt') as file:
  5.     for line in file:
  6.         lines.append(line)
  7.  
  8. sorted_lines = sorted(lines, key=lambda line : int(line.split('\t')[1]), reverse=True)
  9. B_lines = [i if 'B' in i else "" for i in sorted_lines]
  10.  
  11. with open('calls.txt', 'w') as file2:
  12.     for line in sorted_lines:
  13.         if 'A' in line:
  14.             file2.write(line)
  15.             # print(line)
  16.  
  17.     for line in B_lines:
  18.         if line == B_lines[-1]:
  19.             file2.write(line.rstrip())
  20.         else:
  21.             file2.write(line)
  22.             # print(line)
  23.            
Advertisement
RAW Paste Data Copied
Advertisement