Create builder.py
Browse files- builder.py +29 -0
builder.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
+
# Define the names of the input files
|
| 4 |
+
file1_name = "train_0.txt"
|
| 5 |
+
file2_name = "train_1.txt"
|
| 6 |
+
|
| 7 |
+
# Define the name of the output file
|
| 8 |
+
output_file_name = "train.txt"
|
| 9 |
+
|
| 10 |
+
# Open the first input file in read mode
|
| 11 |
+
with open(file1_name, 'r') as file1:
|
| 12 |
+
file1_content = file1.read()
|
| 13 |
+
|
| 14 |
+
# Open the second input file in read mode
|
| 15 |
+
with open(file2_name, 'r') as file2:
|
| 16 |
+
file2_content = file2.read()
|
| 17 |
+
|
| 18 |
+
# Open the output file in write mode and combine the contents
|
| 19 |
+
with open(output_file_name, 'w') as output_file:
|
| 20 |
+
output_file.write(file1_content)
|
| 21 |
+
output_file.write("\n") # Add a newline between the contents of the two files
|
| 22 |
+
output_file.write(file2_content)
|
| 23 |
+
|
| 24 |
+
print(f"Contents of {file1_name} and {file2_name} have been combined into {output_file_name}")
|
| 25 |
+
|
| 26 |
+
os.remove(file1_name)
|
| 27 |
+
os.remove(file2_name)
|
| 28 |
+
|
| 29 |
+
print(f"{file1_name} and {file2_name} have been deleted.")
|