2022.2

Table Of Contents
Examples
Basic example using a CSV file
ImagineyouareaclassicrockfanandyouwanttoextractthedatafromaCSVlistingofallthealbums
inyourcollection.YourgoalistoextractrecordsthatchangewhenevertheartistORthereleaseyear
changes.
Here'swhattheCSVlookslike:
"Artist","Album","Released"
"Beatles","AbbeyRoad",1969
"Beatles","YellowSubmarine",1969
"LedZeppelin","LedZeppelin1",1969
"LedZeppelin","LedZeppelin2",1969
"Beatles","Letitbe",1969
"RollingStones","Letitbleed",1969
"LedZeppelin","LedZeppelin3",1970
"LedZeppelin","LedZeppelin4",1971
"RollingStones","StickyFingers",1971
Note: ThefirstlineisjusttheheaderwiththenamesoftheCSVcolumns.Thedataisalreadysor-
tedperyear,perartist,andperalbum.
YourgoalistoexaminetwovaluesineachCSVrecordandtoactwheneitherchanges.TheDataMap-
perGUIallowsyoutospecifyaOn Changetrigger,butyoucanonlyspecifyasinglefield.Sofor
instance,ifyouweretosettherecordboundarywhenthe"Released"fieldchanges,you'dgetthefirst
fourlinestogetherinsideasinglerecord.That'snotwhatyouwantsincethatwouldincludealbums
fromseveraldifferentartists.Andifyouweretosetitwhenthe"Artist"fieldchanges,thefirstfew
recordswouldbeOKbutneartheend,you'dgetboththeLedZeppelin3andLedZeppelin4albums
insidethesamerecord,eventhoughtheywerereleasedindifferentyears.
Essentially,weneedtocombineboththeseconditionsandsettherecordboundarywhenEITHERthe
yearORtheartistchanges.
Here'swhatthescriptwouldlooklike:
/* Read the values of both columns we want to check */
var zeBand = boundaries.get(region.createRegion("Artist"));
var zeYear = boundaries.get(region.createRegion("Released"));
/* Check that at least one of our variables holding previous values has been
initialized already, before attempting to compare the values */
Page 366