MERGING ALL FILE CONTENS SEPARATED BY ------------------- FILE NAME : CONTENT : PAYLOAD; PYTON CODE




-----------------------------------

 import os


# Input folder

input_folder = "/content"

# Output file

output_file = os.path.join(input_folder, "output.txt")


with open(output_file, "w", encoding="utf-8") as outfile:

    for filename in sorted(os.listdir(input_folder)):

        file_path = os.path.join(input_folder, filename)


        # Skip directories and the output file itself

        if os.path.isfile(file_path) and filename != "output.txt":

            try:

                with open(file_path, "r", encoding="utf-8", errors="ignore") as infile:

                    content = infile.read().strip()

            except Exception as e:

                content = f"<<Could not read file: {e}>>"


            outfile.write(f"file name:{filename};   content: {content}\n")

            outfile.write("-------\n")


print(f"✅ Merged file created at: {output_file}")

Popular posts from this blog

SAP CPI : camle expression in sap cpi , cm, router, filter and groovy script. format

SAP CPI camel conditions and xpath conditions

oauth call to cpi integraiton suite from sap apim