You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
920 B
25 lines
920 B
import os
|
|
|
|
main_directory = './'
|
|
|
|
participant_dirs = range(1, 34)
|
|
|
|
output_file = os.path.join(main_directory, 'merged_notes.txt')
|
|
|
|
with open(output_file, 'w') as outfile:
|
|
for participant in participant_dirs:
|
|
participant_dir = os.path.join(main_directory, str(participant))
|
|
|
|
if os.path.exists(participant_dir):
|
|
for filename in os.listdir(participant_dir):
|
|
if filename.endswith('.txt'):
|
|
file_path = os.path.join(participant_dir, filename)
|
|
|
|
outfile.write(f"\n\n--- Participant {participant} ---\n\n")
|
|
|
|
with open(file_path, 'r') as infile:
|
|
outfile.write(infile.read())
|
|
else:
|
|
print(f"Directory {participant_dir} does not exist.")
|
|
|
|
print("Merging complete. Check the merged_notes.txt file in the main directory.")
|