Scrub EDI Data In File


    Scrub EDI Data In File

    EDIFileScrubber allows developers to scrub EDI files from the file system using the EDIFile property. EDIFileScrubber will also find the necessary delimiters if set.


    // Create a new instance of EDIFileScrubber
    EDIFileScrubber scrubber = new EDIFileScrubber

    scrubber.AutoDetectDelimiters = true;

    // Set the type of EDI file that you are about the scrub
    scrubber.EDIFileType = FileType.X12;

    // Set the source of EDI data, whether you are scrubbing from an in-memory string or a file.  If you are scrubbing from a string then set the EDIDataString property to the EDI data

    scrubber.EDISource = EDISource.File // Or EDISource.DataString

    // Set the EDI file path to scrub

    scrubber.EDIFile = “C:\\EDIFile.txt

    // Set the scrubbing rule (s)

    // Set element 0,1,2,3 of the ISA segment to be replaced by the character ‘Q’

    ScrubRule rule = new ScrubRule();

    rule.SegmentName = “ISA”;

    rule.ReplaceCharacter = ‘Q’;

    rule.ScrubPositions.Add(new ScrubPosition(0));

    rule.ScrubPositions.Add(new ScrubPosition(1));

    rule.ScrubPositions.Add(new ScrubPosition(2));

    rule.ScrubPositions.Add(new ScrubPosition(3));

    // Set composite element 0 element 0 of the SVC segment to be replaced by the character ‘W’

    ScrubRule rule2 = new ScrubRule();

    rule2.SegmentName = “SVC”;

    rule2.ReplaceCharacter = ‘W’;

    rule2.ScrubPositions.Add(new ScrubPosition(0,0));



    // scrub the data

    EDILightWeightDocument doc = scrubber.Scrub();

    in EDI File Scrubber
    Did this article answer your question?