Masking fixed-width files

This walkthrough explains how to mask a fixed-width file by building a package that loads the given file, performs masking and creates a new, masked fixed-width file.

Table of contents
Preconditions
Masking activities that are going to be used
Steps

Preconditions

  • BizDataX Package (Visual Studio project) is created
  • Fixed-width file that is going to be masked is saved in C:\Temp
  • Content of the fixed-width file must have the following format: every row contains data, and each piece of data ("FirstName" and "LastName") is exactly 25 characters long (the file used in this walkthrough can be downloaded here)

Masking activities that are going to be used

  • Step
  • Masking engine
  • Masking iterator
  • API handler
  • Pick US first name from list
  • Pick US last name from list

Steps

  1. From Solution Explorer open the Code.cs file.

  2. In Code.cs add namespace Ekobit.BizDataX.DataMasking.Files and class Customer with properties equal to rows in the fixed-width file.

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Text;  
    using Ekobit.BizDataX.DataMasking.Files;
    
    namespace BizDataXPackage
    {
        /// <summary>
        /// Contains custom code to be used during package execution.
        /// </summary>
        public static class Code
        {
            // TODO: Add your code here
        }
    
        public class Customer
        {
            [Fixed(25)]
            public String FirstName { get; set; }
    
            [Fixed(25)]
            public String LastName { get; set; }
        }
    }
    
  3. Save your changes and build the project.

  4. First few rows of the fixed-width file that is going to be masked:

    Rhiannon                 Velazquez                
    Jasmine                  Conley                   
    Iliana                   Patrick                  
    Toni                     Valencia                 
    Stormy                   Branch                   
    Naomi                    Guzman                   
    Jaylen                   Sampson                  
    Destini                  Downs                    
    
  5. From the Solution Explorer open the Package.xaml file.

  6. Delete the workflow created by default.

  7. Drag the Step activity from the Toolbox into the opened Package.xaml.

  8. Drag the Masking engine from the Toolbox into the Step.

  9. Drag the Masking iterator from the Toolbox into the Masking engine.

  10. In the Select Types pop-up window select Browse for Types... and find Customer.

  11. Click OK on both pop-up windows.

  12. Drag the API handler from the Toolbox into the Masking iterator, in the place that says "Drop data handler here".

  13. In the API handler write:

    api=>api.Fixed().GetHandler<customer>("C:/Temp/Customers.txt","C:/Temp/Customers_masked.txt")
    
  14. Drag the Pick US first name from list masking activity from the Toolbox into the Masking iterator, where it says "Drop activities here".

  15. In the Pick US first name from list masking activity, select FirstName as the "Property".

  16. Do the same for the Pick US last name from list masking activity (select LastName as "Property").

  17. Save your changes and start package execution (Debug->Start Without Debugging).

  18. Open the C:\Temp directory to check for changes. A new file named Customers_masked.txt is created and it contains masked data from the original Customers.txt file.

    Rita                     Navarro                  
    Gregory                  Vaughan                  
    Samuel                   Charles                  
    Francesco                Joyner                   
    Robbie                   Vaughan                  
    Kyla                     Lowe                     
    Alice                    Randall                  
    Kelsey                   Carter                                    
    

Fixed-width file masking Figure 1: Fixed-width file masking

Note: API Handler can be configured with additional options (using line breaks, different encodings, etc): API Handler options Figure 2: API handler options