lol wtf xd no etiqueta bien
This commit is contained in:
29
txtJoin.py
Normal file
29
txtJoin.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import os
|
||||
|
||||
input_directory = "./data"
|
||||
output_file = "join/merged_openbci.txt"
|
||||
separator = "\n" + "=" * 40 + "\n"
|
||||
|
||||
|
||||
if not os.path.isdir(input_directory):
|
||||
raise FileNotFoundError(f"La carpeta especificada no existe: {input_directory}")
|
||||
|
||||
# Obtener lista de archivos TXT
|
||||
txt_files = sorted([f for f in os.listdir(input_directory) if f.endswith(".txt")])
|
||||
|
||||
if not txt_files:
|
||||
raise FileNotFoundError("No se encontraron archivos TXT en la carpeta especificada.")
|
||||
|
||||
# Combinar archivos en uno solo
|
||||
with open(output_file, "w", encoding="utf-8") as outfile:
|
||||
for i, file in enumerate(txt_files):
|
||||
file_path = os.path.join(input_directory, file)
|
||||
|
||||
with open(file_path, "r", encoding="utf-8") as infile:
|
||||
outfile.write(f"### Contenido de: {file} ###\n")
|
||||
outfile.write(infile.read())
|
||||
|
||||
if i < len(txt_files) - 1:
|
||||
outfile.write(separator)
|
||||
|
||||
print(f"Archivos combinados en '{output_file}' exitosamente. ✅")
|
Reference in New Issue
Block a user