On this Page
Table of Contents | ||||
---|---|---|---|---|
|
Snap type: | Transform | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description: | This Snap compares two sorted streams of documents (Original and New) and returns four output streams: Deletions, Insertions, Modified and Unmodified.
| |||||||||||||
Prerequisites: | [None] | |||||||||||||
Support and limitations: |
| |||||||||||||
Account: | Accounts are not used with this Snap. | |||||||||||||
Views: |
| |||||||||||||
Settings | ||||||||||||||
Label | Required. The name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your pipeline. | |||||||||||||
Sort paths | Required. List of paths to sort on. For example, to sort a list of person objects by the field 'firstname', then $person.firstname should be used. Example: $person.firstname Default value: [None] | |||||||||||||
Sort order | Required. Ordering of the sort of the data coming in. Allowed values are ascending or descending. Default value: ascending | |||||||||||||
Output view mapping | Required. Allows you to map output view name to output view type if you removed and then re-added output views. | |||||||||||||
|
|
Examples
Example #1A Diff Made between Two Files Shows What Data Goes to Which Output View
In this example, a diff is made between two files, showing what data goes to which output view.
Let's assume that the original file contains only a rew records (as demonstrated being created in a CSV Generator Snap, but can be a read from a File Reader with a CSV Parser).
By comparison, the new file has over 1000 records (again, demonstrated being created in a CSV Generator Snap).
Because the compare can only be done of sorted stream, each file will need to be sorted by the same column, such as $Last, with the same sort order, so add a Sort Snap after each file input (CSV Generators in this example).
Next, configure the Diff Snap with the Sort path and Sort order.
This results in deleted lines routing to the Deletions view, new lines to the Insertions view, modified lines to the Modified view, and unchanged lines to the Unmodified view.
Example #2Reading an Original csv File and a Modified Version
This example pipeline reads two files, an original csv and a modified version. The modified version includes changes to existing rows, deleted rows and added rows. It creates four different output files based on the diff conditions.
Downloads
Attachments | ||
---|---|---|
|
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|