By the end of this chapter you will be able to:
...
You will also learn how to use an 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 a customer care system and in shops. You will bring all these updates together into a single list.
Read in
...
data sets from
...
files
For this exercise you need two files from the zip file you downloaded in 2 Using Excel Templates, step 5. The files contain updates from the two sources: the customer care service and the shop.
<path>\train\inputData\ChannelPackages\CustomerCareUpdates\CustomerCareUpdates.txt
<path>\train\inputData\ChannelPackages\ShopUpdates\ShopUpdates.txt
- Create a new model with the Name
Channel Package Check
. - Add a file collector to your model and load the data:
- From the model toolbar, drag a
Insert excerpt |
---|
| _file_collector |
---|
| _file_collector |
---|
nopanel | true |
---|
|
into the model. - PhixFlow displays a form the settings tab for the new file collector. Set the Name to
Customer Care Updates
. - In the model, hover your mouse pointer over the
Channel Package Check
file collector to display the context toolbar .Click Image Removed Upload Managed File. and click Insert excerpt |
---|
| _upload_file |
---|
| _upload_file |
---|
nopanel | true |
---|
|
. - Navigate to the directory
<path>\train\inputData\ChannelPackages\CustomerCareUpdates
. - Select the file
CustomerCareUpdates.txt
. and clickImage RemovedUpload, click Open, then click Insert excerpt |
---|
| _upload_button |
---|
| _upload_button |
---|
nopanel | true |
---|
|
. - PhixFlow adds a new stream to the model, called
CustomerCareUpdates
CustomerCareUpdate
. - In the model, hover over the new
CustomerCareUpdates
stream and clickImage Removed Run Analysis.click Insert excerpt |
---|
| _run_analysis |
---|
| _run_analysis |
---|
nopanel | true |
---|
|
- Check the data is loaded. There should be 8 lines of data, with columns for Customer Ref, Sales Date and Package.
- Now the data is loaded into the stream, set the stream to
Insert excerpt |
---|
| _static |
---|
| _static |
---|
nopanel | true |
---|
|
.
- Add another file collector to your model and repeat the process described in step 2. This time:
- Set the file collector Name to
Shop Updates
. - Upload
<path>\train\inputData\ChannelPackages\ShopUpdates\ShopUpdates.txt
. - PhixFlow loads 7 rows of data to this stream.
- Remember to set the steam to
Insert excerpt |
---|
| _static |
---|
| _static |
---|
nopanel | true |
---|
|
.
Snapshot of the Channel Package Check
model so far:
Image RemovedImage Added
Combine
...
the data sets
- Create a new stream in your model and populate its attributes.
- Hover over
CustomerCareUpdates
and click Image Removed Add a new Stream. Insert excerpt |
---|
| _stream_add |
---|
| _stream_add |
---|
nopanel | true |
---|
|
- In the formsettings, set the Name to
Combined Updates
. - In the model, show the stream attributes for
CustomerCareUpdates
. - Select all the attributes and drag them into the form properties for the
Combined Updates
stream. Drop them into the Attributes section.
Save your model layout.- Click
Insert excerpt |
---|
| _finish |
---|
| _finish |
---|
nopanel | true |
---|
|
.
- To save your model, in the model toolbar click .
- Connect the
ShopUpdates
stream to the Combined Updates
stream.- Hover over
ShopUpdates
and click Image Removed Add a new Connector. Click Combined Updates
to link the pipe to the stream.
Info |
---|
When PhixFlow adds data to a stream via a pipe, it you connect streams, PhixFlow automatically adds a reference to the input pipe name. This appears in the attribute expression. To merge the this data sucessfully successfully, you must update the attribute expressions to remove the in. prefix; see step 4 below. |
- Fix all the attribute expressions.
- Double-click on
Combined Updates
to open its configuration formsettings tab. For each attribute: - In the Attributes section, double-click on an attribute to open its formsettings.
- In the form for the attribute, in the Basic Settings section, edit the Expression to remove
in.
and press Image Removed.click Insert excerpt |
---|
| _finish |
---|
| _finish |
---|
nopanel | true |
---|
|
- In the
Combined Updates
stream form, press Image Removed to save the changes. - Run analysis on
Combined Updates
. - Check that you have the correct number of records in this stream when the analysis is complete.
- Check the data set you generated to make sure that every field in every output record has been populated.
...
- settings tab, click
Insert excerpt |
---|
| _finish |
---|
| _finish |
---|
nopanel | true |
---|
|
to save and close. - In the model, hover your mouse pointer over
Combined Updates
and click Insert excerpt |
---|
| _run_analysis |
---|
| _run_analysis |
---|
nopanel | true |
---|
|
. - When the stream has run, check that the stream has:
- the columns CustomerRef, Sales Date and Package
- 15 rows
- all cells have data.
The stream default view:
Image Added
Snapshot of the Chanel Package Check model so far:
Image Added
Record the source for each update
You will now update your configuration settings to record the source for each update, in the set of combined updates. To do this:
- Update To update the name of the pipe from the
CustomerCareUpdates
stream to the Combined Updates
stream CustomerCareUpdates
.Double-:- In the model, click on the pipe to open its configuration formits settings tab.
- Update the Set Name to
CC
.Press Image Removed to save your changes - Click
Insert excerpt |
---|
| _finish |
---|
| _finish |
---|
nopanel | true |
---|
|
to save and close the pipe settings.
- Update the name of the pipe from
ShopUpdates
to shop
the ShopUpdates
file collector to the ShopUpdates
stream.
- In the model, click on the pipe to open its settings tab.
- Set Name to shop
- Click
Insert excerpt |
---|
| _finish |
---|
| _finish |
---|
nopanel | true |
---|
|
to save and close pipe settings.
- Double-click the stream
Combined Updates
to open its configuration formits settings tab. - In the Attributes section, click add a new attribute and set:
- Name:
Source
. Expression :
Code Block |
---|
if (_pipeName == "CC",
"Customer Care"
,
"Shop"
) |
- Click
Insert excerpt |
---|
| _finish |
---|
| _finish |
---|
nopanel | true |
---|
|
to save and close the attribute settings.
- To make
Source
the first attribute in the stream, drag it to the top of the attributes list.Press Image Removed in the main stream configuration form - Click
Insert excerpt |
---|
| _finish |
---|
| _finish |
---|
nopanel | true |
---|
|
to save and close the stream settings. - Run analysis on
Combined Updates
. - Check the output data set and make sure that the source has been recorded on each record correctly.
Image Added