Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # Filename: data_marker.py
- # Author: Jeoi Reqi
- # Data Marker is a simple script to be used along with the Split Data With Markers Python Script
- # Script: https://pastebin.com/tEFTfv7s
- import os
- # Set Markers At Specified Number Of Lines (Eg;) 100 With Marker "**"
- def insert_marker(input_file, output_file, lines_per_marker=100, marker="**"):
- with open(input_file, 'r', encoding='utf-8') as file:
- lines = file.readlines()
- total_lines = len(lines)
- total_markers = total_lines // lines_per_marker
- print(f"Total number of markers: {total_markers}")
- with open(output_file, 'w', encoding='utf-8') as output:
- for i in range(total_markers):
- start_index = i * lines_per_marker
- end_index = min((i + 1) * lines_per_marker, total_lines)
- chunk = lines[start_index:end_index]
- # Combine the lines into a single string
- combined_data = ''.join(chunk)
- if __name__ == "__main__":
- current_directory = os.getcwd()
- input_file_path = os.path.join(current_directory, 'isoon_chat.txt') # Edit Input To Your Desired File Name
- output_file_path = os.path.join(current_directory, 'output_isoon_chat_with_markers.txt') # Edit Output File Name To Your Desired File Name
- insert_marker(input_file_path, output_file_path, lines_per_marker=100, marker="**") # Insert The Markers
- print("Script execution complete.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement