File size: 917 Bytes
cb5e776
 
 
 
 
 
 
 
 
 
079c4e2
cb5e776
 
 
079c4e2
cb5e776
 
 
079c4e2
cb5e776
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os

# Define the names of the input files
file1_name = "train_0.txt"
file2_name = "train_1.txt"

# Define the name of the output file
output_file_name = "train.txt"

# Open the first input file in read mode
with open(file1_name, 'r', errors='ignore') as file1:
    file1_content = file1.read()

# Open the second input file in read mode
with open(file2_name, 'r', errors='ignore') as file2:
    file2_content = file2.read()

# Open the output file in write mode and combine the contents
with open(output_file_name, 'w', errors='ignore') as output_file:
    output_file.write(file1_content)
    output_file.write("\n")  # Add a newline between the contents of the two files
    output_file.write(file2_content)

print(f"Contents of {file1_name} and {file2_name} have been combined into {output_file_name}")

os.remove(file1_name)
os.remove(file2_name)

print(f"{file1_name} and {file2_name} have been deleted.")