0026 Insert records into the file

A practical Advanced ETL Processor example for building, testing, and adapting one automation workflow.

Advanced ETL Processor
4.9 ★★★★★ Based on 16 reviews on Capterra See all reviews on Capterra →

Use this example to build one working automation package, test it safely, and then adapt it to your own files, folders, or data rules. Start small. Automation is helpful; automated mistakes are just faster mistakes.

Customer question

Question from the customer

I have the following file.

Source file

Source row
HEAD01,Line1
HEAD01,Line2
HEAD02,Line4
HEAD02,Line5
HEAD03,Line3

I want to create a file with each header inserted before its matching lines.

Desired output

Output row
HEAD01
Line1
Line2
HEAD02
Line4
Line5
HEAD03
Line3

Original forum post

Answer

Yes. This example is based on 0025 Merge Header and Lines file, then adds the missing header rows into the output flow.

addheader

How it works

  1. The first transformation adds the header number field.
  2. The next transformations add RN fields to the data: 1 for headers and 2 for lines.
  3. The data is merged using the Union transformation.
  4. The data is sorted using F2 and RN fields.
  5. The result is written into the target file. It is the kind of small formatting job that looks harmless until someone has to do it by hand every week.

To view the example follow the steps below

  1. Download and install Advanced ETL Processor [Link]
  2. Download and unzip the example [Link]
  3. Create a new transformation and open the .ats file
  4. Double-click the Reader object and amend the source file path
  5. Double-click the Transformer object
  6. Double-click the Lookup object and amend the source file path
  7. Double-click the Writer object and amend the target file path
  8. Press the green arrow to run the transformation.

Related Advanced ETL Processor resources

For more automation examples, review the Advanced ETL Processor tutorials, read the WIKI, or download the Advanced ETL Processor Enterprise trial.