From 4b9e07bde8a23ee728ba588f530d10241f8983c5 Mon Sep 17 00:00:00 2001 From: guis98 <guis98@mi.fu-berlin.de> Date: Mon, 12 Aug 2024 10:13:35 +0000 Subject: [PATCH] upload get_stuff.py --- get_stuff.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 get_stuff.py diff --git a/get_stuff.py b/get_stuff.py new file mode 100644 index 0000000..c0e382f --- /dev/null +++ b/get_stuff.py @@ -0,0 +1,22 @@ +import os +import glob + +# Define the source and destination directories +source_dir = './data/frames_auto_annotate_labels' +dest_dir = './train/labels' + +# Get a list of all text files in the source directory +text_files = glob.glob(os.path.join(source_dir, '*.txt')) + +# Process each text file +for file_path in text_files: + with open(file_path, 'r') as file: + lines = file.readlines() + + # Replace "14" with "0" at the start of each line, or discard the line + new_lines = [line.replace('14', '0', 1) if line.startswith('14') else '' for line in lines] + + # Write the new lines to a file in the destination directory + dest_file_path = os.path.join(dest_dir, os.path.basename(file_path)) + with open(dest_file_path, 'w') as file: + file.writelines(new_lines) \ No newline at end of file -- GitLab