Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- infos = []
- with open("data.txt", encoding="utf8") as f:
- temp_data = ""
- temp_number = 10000000000
- line_count = 0
- for line in f:
- #print(line, end="")
- if line.startswith("|-"):
- infos.append((temp_data, temp_number))
- #print(temp_data, temp_number)
- #input()
- temp_data = ""
- temp_number = 10000000000
- line_count = 0
- temp_data += line
- if line_count == 2:
- line = re.sub("(<!--.*?-->)", "", line)
- temp_number = int(re.sub('[^0-9]','', line))
- #print(temp_number)
- #input()
- line_count += 1
- infos.sort(key=lambda x: -x[1])
- with open("data_sorted.txt", mode="w", encoding="utf8") as f:
- f.write(''.join(x[0] for x in infos))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement