By the end of this chapter you will be able to:
- Combine Data Sets data sets (a union) with a Calculate Streamcalculate stream
- Record the source for each record in a Streamstream
- Use the internal variable _pipeName
In this exercise you will produce a single list of updates to customers' Cable TV packages. Customers can update their packages both through the a Customer Care system and in shops. You will bring all these updates together into a single list.
...
...
Reading in data sets from files
- Create a new model with Name:
Channel Package Check
There are two files containing updates from the two sources (Customer Care, and Shop).
Customer Care updates
A file containing details of customer care updated can be found in the input files, at:
…\inputData\ChannelPackages\CustomerCareUpdates\CustomerCareUpdates.txt
Shop updates
A file containing details of shop updates can be found in the input files, at:
…\inputData\ChannelPackages\ShopUpdates\ShopUpdates.txt
...
Load file data into
...
PhixFlow
- Add a
...
- file collector to your model
- Call this:
Customer Care Updates
- Navigate to the directory …\
- Call this:
...
- inputData\ChannelPackages\CustomerCareUpdates
- Select the file CustomerCareUpdates.txt – and complete the automatic
...
- file collector and
...
- stream configuration
- Add another
...
- file collector to your model
- Call this:
Shop Updates
- Navigate to the directory …\inputData\ChannelPackages\ShopUpdates
- Select the file ShopUpdates.txt – and complete the automatic
- Call this:
...
- file collector and
...
- stream configuration
- Run both
...
- streams and check that data is loaded into each one from the files
...
Combine data sets
- Create a new
...
- stream in your model:
- Hover over
CustomerCareUpdates
and
- Hover over
...
- press - Add a new Stream
- Call the new
...
- stream
Combined Updates
- Drag all attributes from
CustomerCareUpdates
toCombined Updates
- stream
- Remember to save your model layout
- Add a pipe from the other
...
- stream:
- Hover over
ShopUpdates
and
- Hover over
...
- press - Add a new Connector
- Click on
Combined Updates
to link the pipe to the output
...
- stream
- To complete configuration of
Combined Updates
:- Double
...
- click on
Combined Updates
to open the configuration form - To make the union work, you need to update the
- click on
...
- expression for each
...
- attribute:
...
- you must remove the reference to the input pipe that
...
- PhixFlow has automatically added to the start of each
...
- expression, e.g.:
- Update the expression
- expression, e.g.:
Code Block |
---|
in.CustomerRef |
to
Code Block |
---|
CustomerRef |
- Press Press in the main Stream stream configuration form
- Run Analysis analysis on
Combined Updates
- Check that you have the correct number of records in this Stream stream when the Analysis analysis is complete
- Check the data set you generated – make sure that every field in every output record has been populated
...
...
Record source for each update
You will now update you configuration to record the source for each update, in the set of combined updates. To do this:
- Update the name of the pipe from the Stream stream
CustomerCareUpdates
:- Double - click on the pipe to open the configuration details
- Update the Name to:
CC
- Press Press to save your changes
- Update the name of the pipe from
ShopUpdates
to:shop
- Double - click the Stream stream
Combined Updates
to open the configuration form- Add a new Attribute with Name:
Source
- Set the Expression of Source to:
- Add a new Attribute with Name:
Code Block |
---|
if (_pipeName == "CC", |
...
"Customer Care" |
...
, |
...
"Shop" |
...
) |
- Make
Source
the first Attribute attribute in the Streamstream: drag it to the top of the Attributes attributes list - Press Press in the main Stream stream configuration form
- Run analysis on
Combined Updates
- Check the output data set and make sure that the source has been recorded on each record correctly