Wiki source code of Header line

Version 28.1 by Erik Bakker on 2022/06/10 13:12

Hide last authors
Erik Bakker 21.1 1 {{container}}{{container layoutStyle="columns"}}(((
Erik Bakker 28.1 2 In this microlearning, we will learn how you can define a header line in which you specify the naming of the various columns. Some external systems require a header line when you supply them with data via a flat file that is placed somewhere.
eMagiz 1.1 3
Erik Bakker 21.1 4 Should you have any questions, please contact [[academy@emagiz.com>>mailto:academy@emagiz.com]].
eMagiz 1.1 5
Erik Bakker 28.1 6 * Last update: May 28th, 2021
eMagiz 1.1 7 * Required reading time: 5 minutes
8
9 == 1. Prerequisites ==
10
11 * Basic knowledge of the eMagiz platform
12
13 == 2. Key concepts ==
14
Erik Bakker 28.1 15 This microlearning centers around learning how to place a header line on a flat-file output.
eMagiz 1.1 16
Erik Bakker 28.1 17 By header line we mean: A line in the output that defines the naming of the various columns
eMagiz 1.1 18
Erik Bakker 28.1 19 Some external parties require that the first line in the flat file output (i.e. CSV) is filled with column names (i.e. headers). In eMagiz, we call this line a header line.
eMagiz 1.1 20
Erik Bakker 28.1 21 == 3. Header line ==
eMagiz 1.1 22
Erik Bakker 28.1 23 In this microlearning, we will learn how you can define a header line in which you specify the naming of the various columns. Some external systems require a header line when you supply them with data via a flat file that is placed somewhere. The header line is the first line in the flat file output. Within this line, the various column names are specified for clarity.
eMagiz 1.1 24
Erik Bakker 28.1 25 To add such a header line in eMagiz you need to navigate to the Create phase of eMagiz and open the exit flow in which you want to drop the file to a certain location. Within the context of this flow, we need to add functionality that will ensure that a header line is written to the output before any functional lines are added. To do so first enter "Start Editing" mode on flow level. After you have done so please add a file outbound channel adapter to the flow including an input channel. We will use this component to write our header line to the flat file output.
eMagiz 1.1 26
Erik Bakker 28.1 27 Ensure that the directory to which you reference is the same as in your functional file outbound channel adapter.
eMagiz 1.1 28
Erik Bakker 28.1 29 [[image:Main.Images.Microlearning.WebHome@novice-file-based-connectivity-header-line--file-outbound-channel-header-line.png]]
eMagiz 1.1 30
Erik Bakker 28.1 31 Now it is time to turn our attention to the Advanced tab. For the Mode select Ignore. Select this option to ensure that the header line is only written down once when there is no output created yet and not somewhere in the middle, in the end, or every time. Furthermore, select the option Append New Line to ensure that the remainder of the information is not appended to the same line.
eMagiz 1.1 32
Erik Bakker 28.1 33 [[image:Main.Images.Microlearning.WebHome@novice-file-based-connectivity-header-line--file-outbound-channel-header-line-advanced.png]]
eMagiz 1.1 34
Erik Bakker 28.1 35 After you have done so we need to add a standard transformer that defines the various column names to be written to the flat file output. To do so add the standard transformer component to the canvas including an input channel. After you have done so define the relevant SpEL expression. In this case, we advise using a property value that represents a string of column names. The value of the property should be something as follows:
eMagiz 1.1 36
Erik Bakker 28.1 37 'Header1;Header2;Header3;Header4'
eMagiz 1.1 38
Erik Bakker 28.1 39 Do note that the separator, in this case, needs to match the requirements of the external system. At the flow configuration level, the standard transformer should look as follows.
eMagiz 1.1 40
Erik Bakker 28.1 41 [[image:Main.Images.Microlearning.WebHome@novice-file-based-connectivity-header-line--define-columns-names.png]]
eMagiz 1.1 42
Erik Bakker 28.1 43 Our last step is to ensure that this piece of logic is tied to the main flow and is executed before writing the functional line(s) to the output file. To make that happen we need to add a wiretap to the flow. With the help of this functionality, you can define which part of the logic takes precedence over another part of the logic. To do so double click on the channel on which you want to place a wiretap, select the option wiretap and select the correct wiretap channel. After you have done this the result should be something as follows:
eMagiz 1.1 44
Erik Bakker 28.1 45 [[image:Main.Images.Microlearning.WebHome@novice-file-based-connectivity-header-line--wiretap-result.png]]
eMagiz 1.1 46
Erik Bakker 28.1 47 With these couple of steps, you have now successfully added logic to your flow that will ensure that a header line is added before any functional line(s) are written to the output file.
eMagiz 1.1 48
49 == 4. Assignment ==
50
Erik Bakker 28.1 51 Configure an exit in which you define and write a header line to a flat-file output before adding functional lines.
eMagiz 1.1 52 This assignment can be completed with the help of the (Academy) project that you have created/used in the previous assignment.
53
54 == 5. Key takeaways ==
55
Erik Bakker 28.1 56 * The header line contains the names of the columns of the flat file output
57 * Use the Ignore mode to ensure the header line is created once
58 * Use the wiretap to ensure the header line is created first
eMagiz 1.1 59
60 == 6. Suggested Additional Readings ==
61
62 There are no suggested additional readings on this topic
63
64 == 7. Silent demonstration video ==
65
66 This video demonstrates how you could have handled the assignment and gives you some context on what you have just learned.
67
Erik Bakker 28.1 68 {{video attachment="novice-file-based-connectivity-header-line.mp4" reference="Main.Videos.Microlearning.WebHome"/}}
eMagiz 1.1 69
Erik Bakker 21.1 70 )))((({{toc/}}))){{/container}}{{/container}}