BDO TOOLS  -  Add Fields BDO Tools Align Fields

Use the Add Fields tool to insert and/or append fields to lines of a text file.


Unlike the Organise Fields tool which restricts the number of fields per line to a maximum of 25 and requires each input line to contain the same number of fields, the Add Fields tool can accommodate an unlimited number of fields per line, and there is no requirement for each line to contain the same number of fields, although by selecting the Enforce Strict Field Count box this latter requirement can be activated.

Procedure

  1. Choose input and output files. See Force ANSI / Remove BOM.
    As a visual aid, up to the first 9 lines of the input file are displayed in the Input Top area.
  2. Enter the number of fields you wish to insert or append in the Add Fields box.
  3. Optionally,
    • Change the delimiter in the Delimiter box. When blank, a comma is used as the default delimiter.
    • Change the output field quote marks using the Quotes drop-down control. This applies only to the new fields that are to be inserted / appended. The original input file quotes are not altered.
    • Select the Merge Adjacent Delimiters control.
    • Select the Match Fields control.
      When the Match Fields control is selected, the Enforce Strict Field Count control is automatically selected.
    • Select the Enforce Strict Field Count control.
    • Select the Enclosed control.
      When the Enclosed control is selected, the new fields are inserted / appended within the chosen Enclosed By characters.
    • Select the Align Fields control.
    • Select the Append All control. When selected, all Insert Fields After boxes are hidden.
    • Enter positional values in the Insert Fields After boxes. If all of the Insert Fields After boxes are left blank all of the new fields will be appended.
  4. Click the Check button.
    As a visual aid, the result of your settings selections when applied to the lines displayed in the Input Top area are displayed in the Output Top area.
  5. Click OK to create the output file.

 

 

By default, the Add Fields tool prepends fields when it encounters empty Insert Fields After boxes that are numbered less than a box with a user-supplied non-zero position. For empty boxes numbered higher than the highest non-zero user-supplied position box, fields are appended. If all boxes are empty, all fields are appended.

 

For example, in the screen display shown above, five of the Insert Fields After boxes are empty (boxes 1, 2, 3, 5 and 7).

The first three empty boxes are treated as if the user had entered a number 0 in each of the boxes, and three fields are therefore inserted after field 0 - i.e. they are prepended. Since Insert Fields After box number 6 contains the user-supplied value of 0, a fourth field is also prepended.

Insert Fields After box number 4 contains the user-supplied value 2 and a field is therefore inserted after field 2 of each line of the input file.

The other two empty boxes (boxes 5 and 7) are numbered higher than the highest non-zero user-supplied position box (box 4) and two fields are therefore appended.

Limitations

  • The maximum number of fields that can be inserted is 10.
  • The maximum number of fields that can be appended is 99.
These limitations can be overcome by using the output file generated by the Add Fields tool as the input file for another run.

Caution

The output file generated by the Add Fields tool will always, obviously, be larger in size than the input file, but the difference in size can be significant when the Align Fields control is selected.
 
Copyright © 2017 Brian D. Ogilvie www.bdozone.com  :