This example shows how to create a simple dataflow that reads data from a file, sorts it, then writes it to a file. Since this dataflow reads data from a file and writes its output to a file, it is a job: a dataflow that performs batch processing. (The other primary type of dataflow, a service, performs interactive processing by means of an API or web service call to the server.)
-
The first step will be to create some sample data to use as input to your
dataflow. Using a text editor, create a file that looks like this:
FirstName,LastName,Region,Amount Alan,Smith,East,18.23 Jeannie,Wagner,North,45.43 Joe,Simmons,East,10.87 Pam,Hiznay,Central,98.78
- Save the file in a convenient location.
- Click Start > Programs > Precisely > Spectrum Technology Platform > Client Tools > Enterprise Designer.
- Click File > New > Dataflow > Job.
-
You are now ready to begin creating your dataflow. The first step is to define
the input to the dataflow. To do this:
-
Drag a Read from File stage to the canvas:
- Double-click the Read from File stage on the canvas.
- In the File name field, specify the file you created for this task.
- In the Record type field, choose Delimited.
- In the Field separator field, select Comma (,).
- Select the First row is header record check box.
- Click the Fields tab.
-
Click Regenerate then click
Yes.
The stage is automatically configured for the fields in your input file.
- Click Detect Type. This scans the input file and determines the appropriate data type for each field. Notice that the type for the Amount filed changes from string to double.
-
Click OK.
You have finished configuring the Read from File stage.
-
Drag a Read from File stage to the canvas:
-
Next, you will add a stage that will sort the records by region. To do
this:
- Drag the Sorter stage to the canvas
-
Click the solid black triangle on the right side of the Read from File
stage (the output port) and drag it to the left side of the Sorter stage
on the canvas to create a channel connecting Read from File and Sorter.
Your dataflow should look like this:
- Double-click the Sorter stage on the canvas.
- Click Add.
- In the Field Name field, select Region.
-
Click OK.
You have finished configuring the Sorter stage.
-
Finally, you will define the output file where the dataflow will write its
output. To do this:
- Drag a Write to File stage to the canvas.
-
Click the solid black triangle on the right side of the Sorter stage
and drag it to the left side of the Write to File stage on the
canvas.
Your dataflow should look like this:
- Double-click the Write to File stage.
- In the File name field, specify an output file. This can be any file you want.
- In the Field separator field, select Comma (,).
- Select the First row is header record check box.
- Click the Fields tab.
- Click Quick Add.
- Click Select All then click OK.
-
Using the Move Up and Move
Down buttons, reorder the fields so that they are in the
following order:
- FirstName
- LastName
- Region
- Amount
This will make the records in your output file have the fields in the same order as your input file.
- You have finished configuring Write to File. Click OK.
- In Enterprise Designer, select File > Save.
- Give your dataflow a name and click OK.
- Your dataflow is now ready to run. Select Run > Run Current Flow.
- The Execution Details window appears and shows the status of the job. Click Refresh. Once the status shows Succeeded click Close.
Open the output file you specified in the Write to File stage. You will see that the records have been sorted by region as you specified in the Sorter stage.
FirstName,LastName,Region,Amount
Pam,Hiznay,Central,98.78
Alan,Smith,East,18.23
Joe,Simmons,East,10.87
Jeannie,Wagner,North,45.43
Congratulations! You have designed and run your first job dataflow.