Log out?

Exercise 4.3 – Transforming Conditional Fixed-Width Files

Purpose:

To practice transforming fixed-width files using the File Spec Editor and Field Record Control conditions.



Steps:

  1. Create a Route
    1. From the eiConsole File Management screen, select the “Add Route” button.
    2. In the dialog that appears, enter the name “Conditional Fixed-Width Files” and select “OK”.
    3. The Route should now appear in the table on the screen. Double click it to open it.


  2. Document Source System
    1. Select the “Source System” stage in the “Route Editing Grid”. The configuration panel will appear at the bottom.
    2. Change the “System Name” to “Text File”
    3. Select the “Choose Source Icon” button, and scroll down to select one of the plain file icons


  3. Configure the Listener
    1. Select the “Listener” stage in the “Route Editing Grid”. The configuration panel will appear at the bottom.
    2. Select “Directory / File” from the “Listener Type” selection box. Optionally, click the “…” button to open the Module Search Dialog, which provides a faster way to find the module you’re looking for.
    3. Assign a polling directory, using the “…” button to open the file chooser. The polling directory should NOT be the directory with all the sample files, since files will be moved/deleted by the listening process.


  4. Add Source Transformation Module
    1. Select the “Source Transform” stage in the “Route Editing Grid”. The configuration panel will appear at the bottom.
    2. Click the “Add Format” button. In the dialog that appears, name the Format “People Conditional Fixed File Spec”, and click “OK”. The transformation configuration panel will appear below.
    3. Select “Delimited and Fixed-Width File” from the “Transformation Module” selection box. Optionally, click the “…” button to open the Module Search Dialog, which provides a faster way to find the module you’re looking for.
    4. In the new configuration panel that appears below, select the “Edit” button next to the “File Spec” configuration field to open the “File Spec Editor”.


  5. Create a File Spec
    1. When the “File Spec Editor” opens, a dialog called “Select for New File Type” will be present. In the sole selection box, choose the last option in the list, called “User-defined”, and click “Next”.
    2. In the new screen, leave “Record Style” set to “Delimited” with the “Record Delimiter” as “\n”. Change the “Field Style” to be “Fixed Width”. Finally, click “Save”.
    3. In the “File Spec Editor”, the left-hand panel is a tree where the specification will be built.
    4. Right click on the root Node of the tree, called “Base”, and select “Add New Record”. In the dialog that pops up, enter “Animal” as the record name, and click “OK”.
    5. Right click on the “Animal” record to add the following fields. After adding each field, set the length for that field in the configuration panel below.
      1. RecType (3)
      2. ID (5)
      3. Type (10)
      4. Name (10)
      5. Flavor (5)
    6. Right click on the root node of the tree, called “Base”, and select “Add New Record”. In the dialog that pops up, enter “Building” as the record name, and click “OK”.
    7. Right click on the “Building” record to add the following fields. After adding each field, set the length for that field in the configuration panel below.
      1. RecType (3)
      2. ID (5)
      3. Type (10)
      4. Value (6)
    8. Right click on the root node of the tree, called “Base”, and select “Add New Record”. In the dialog that pops up, enter “Employee” as the record name, and click “OK”.
    9. Right click on the “Employee” record to add the following fields. After adding each field, set the length for that field in the configuration panel below.
      1. RecType (3)
      2. ID (5)
      3. Type (10)
      4. Salary (8)
    10. Right click on the root node of the tree, called “Base”, and select “Add New Record”. In the dialog that pops up, enter “Unknown” as the record name, and click “OK”.
    11. Right click on the “Unknown” record to add the following fields. After adding each field, set the length for that field in the configuration panel below.
      1. Unknown (10)


  6. Create a Field Record Control
    1. Now that the spec is complete, right click on the “Base” node at the root of the tree, and select “Specify Record Control”.
    2. From the dialog box that appears, click the “Define new…” button, to open a second dialog, “Add new Record Control”.
    3. In the “Record Control Type” selection box, choose “Field Record Control”. Then click “Add Converter” to save the changes.
    4. The “Field Record Control” item should be populated in the selection box in the “Add Record Control Instance” dialog. Click “Select” to save the changes.
    5. Select the “Field Record Control” node that is now in the tree. The bottom panel should display a new configuration panel with its own tree.
    6. Right-click on “Control Cases” in the bottom panel, and choose “Add”. A dialog will appear.
    7. For the “Use Record” field, input “Animal”. For “Test Field”, input “RecType”. For “Value”, input “ANI”. Click “OK” to save.
    8. Right-click on “Control Cases” again to add another case. In the dialog, for “Use Record” input “Building”, for “Test Field” input “RecType”, and for “Value” input “BUI”. Click “OK” to save.
    9. Right-click on “Control Cases” again to add another case. In the dialog, for “Use Record” input “Employee”, for “Test Field” input “RecType”, and for “Value” input “EMP”. Click “OK” to save.
    10. Right click on the “Default Case” node, and select “Define”. In the dialog that appears, for “Default Record Name”, input “Unknown”. “Click “OK” to save the changes.
    11. Find the button with the icon of a floppy disk in the toolbar above the tree, and click it. Enter “people-file-spec” as the name of the specification to save it.
    12. After saving it, press the “X” button in the top right of the screen to close the “File Spec Editor” and return to the “Route Editing Grid”.


  7. Configure the Transport
    1. Select the “Transport” stage in the “Route Editing Grid”. The configuration panel will appear at the bottom.
    2. Select “Directory / File” from the “Transport Type” selection box. Optionally, click the “…” button to open the Module Search Dialog, which provides a faster way to find the module you’re looking for.
    3. Select the “Target Directory”, using the “…” button to open the file chooser.
    4. Set “farm-output” as the “Target File Name”.
    5. Set “xml” as the “Target File Extension”.


  8. Document the Target System
    1. Select the “Target System” stage in the “Route Editing Grid”. The configuration panel will appear at the bottom.
    2. Change the “System Name” to “XML File”
    3. Select the “Choose Target Icon” button, and scroll down to select one of the XML icons


  9. Prepare to Test
    1. In the menu bar at the top, select “Route” -> “Testing Mode”. Make sure the changes to the Route are saved.
    2. Copy the file called “farm.txt” from the “Samples” directory provided into the directory chosen as the polling directory.


  10. Perform the Test
    1. At the top of the “Testing Mode” screen, select the “Execute Test” button.
    2. If the “Route” was configured successfully, all the Stages should light up with green checkmarks.
    3. In the OS File Explorer, open the directory selected as the “Target Directory”. The file “farm-output.xml” should be there, with the contents of the original file transformed into XML.


  11. Output Files
    1. Compare the results from the exercise with the following example output files to see if they are correct.
      1. farm-output.xml


This is a unique website which will require a more modern browser to work! Please upgrade today!

Thanks!

Our editors are notified.

Close