I have 3 files

1- contains 600 line of "case 1 :", "case 2 :", "case 3 :"

2- contains 600 line of "pictureBox1.Image = Properties.Resources._1;"

3- contains 600 line of "Break;"

and I want to merge them all in this format

                case 1:
                    pictureBox1.Image = Properties.Resources._1;
                case 2:
                    pictureBox1.Image = Properties.Resources._2;
                case 3:
                    pictureBox1.Image = Properties.Resources._3;
                case 4:
                    pictureBox1.Image = Properties.Resources._4;
                case 5:
                    pictureBox1.Image = Properties.Resources._5;

is this even possible to merge with custom format ?

  • Ofcourse its possible. It might require a script, but its pissible. The question to me though is "why"? It would likely be easier to just use file 2 and recreate ttje ither data programatically.
    – davidgo
    Dec 4, 2022 at 4:36

1 Answer 1


Yes, it is possible to merge the three files into the format you described. You can use a simple script to do this. Here is an example of how you could do it in Python:

# Open the first file in read mode
with open('file1.txt', 'r') as file1:
  # Open the second file in read mode
  with open('file2.txt', 'r') as file2:
    # Open the third file in read mode
    with open('file3.txt', 'r') as file3:
      # Open a new file in write mode
      with open('output.txt', 'w') as output:
        # Iterate over the lines in the first file
        for line1 in file1:
          # Read the corresponding lines from the second and third files
          line2 = file2.readline()
          line3 = file3.readline()
          # Format the lines as described in the question
          output_line = '                ' + line1.strip() + ':\n'
          output_line += '                    ' + line2.strip() + ';\n'
          output_line += '                    ' + line3.strip() + ';\n'
          # Write the formatted line to the output file

This script reads each line from the first file, and then reads the corresponding lines from the second and third files. It then formats these lines as described in the question, and writes the result to a new file called output.txt.

You can adjust the code to use different file names and to add any additional formatting that you want.

  • thanks, but It's not working...I changed the 'file1.txt' to 'C:\Users\Abdullah\Desktop\1.txt' and all other names to the path and installed python and ran the script why it's not working ?
    – Sycho AN
    Dec 4, 2022 at 11:09
  • I replaced \ with \\ and it worked thanks
    – Sycho AN
    Dec 4, 2022 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.