Wiki source code of Header line

Last modified by Erik Bakker on 2024/08/26 12:26

Hide last authors
Erik Bakker 21.1 1 {{container}}{{container layoutStyle="columns"}}(((
Erik Bakker 35.1 2 In this microlearning, we’ll cover how to add a header line to a flat-file output in eMagiz. A header line is the first row in your CSV file, defining the names of the columns for clarity. We’ll walk through the steps to configure this in your output flow, ensuring that your external systems receive data with properly labeled columns. By the end of this microlearning, you'll know how to set up and manage header lines to meet your data formatting requirements.
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
6 == 1. Prerequisites ==
7
8 * Basic knowledge of the eMagiz platform
9
10 == 2. Key concepts ==
11
Erik Bakker 28.1 12 This microlearning centers around learning how to place a header line on a flat-file output.
eMagiz 1.1 13
Erik Bakker 28.1 14 By header line we mean: A line in the output that defines the naming of the various columns
eMagiz 1.1 15
Erik Bakker 28.1 16 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 17
Erik Bakker 28.1 18 == 3. Header line ==
eMagiz 1.1 19
Erik Bakker 28.1 20 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 21
Erik Bakker 28.1 22 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 23
Erik Bakker 28.1 24 Ensure that the directory to which you reference is the same as in your functional file outbound channel adapter.
eMagiz 1.1 25
Erik Bakker 28.1 26 [[image:Main.Images.Microlearning.WebHome@novice-file-based-connectivity-header-line--file-outbound-channel-header-line.png]]
eMagiz 1.1 27
Erik Bakker 28.1 28 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 29
Erik Bakker 28.1 30 [[image:Main.Images.Microlearning.WebHome@novice-file-based-connectivity-header-line--file-outbound-channel-header-line-advanced.png]]
eMagiz 1.1 31
Erik Bakker 28.1 32 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 33
Erik Bakker 28.1 34 'Header1;Header2;Header3;Header4'
eMagiz 1.1 35
Erik Bakker 28.1 36 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 37
Erik Bakker 28.1 38 [[image:Main.Images.Microlearning.WebHome@novice-file-based-connectivity-header-line--define-columns-names.png]]
eMagiz 1.1 39
Erik Bakker 28.1 40 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 41
Erik Bakker 28.1 42 [[image:Main.Images.Microlearning.WebHome@novice-file-based-connectivity-header-line--wiretap-result.png]]
eMagiz 1.1 43
Erik Bakker 28.1 44 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 45
Eva Torken 30.1 46 == 4. Key takeaways ==
eMagiz 1.1 47
Erik Bakker 28.1 48 * The header line contains the names of the columns of the flat file output
49 * Use the Ignore mode to ensure the header line is created once
50 * Use the wiretap to ensure the header line is created first
eMagiz 1.1 51
Eva Torken 30.1 52 == 5. Suggested Additional Readings ==
eMagiz 1.1 53
Carlijn Kokkeler 31.1 54 * [[Use Cases (Menu)>>doc:Main.eMagiz Academy.Use Cases.WebHome||target="blank"]]
55 ** [[File based Connectivity (Navigation)>>doc:Main.eMagiz Academy.Use Cases.File based Connectivity.WebHome||target="blank"]]
56 * [[Intermediate (Menu)>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.WebHome||target="blank"]]
Carlijn Kokkeler 32.1 57 ** [[File based Connectivity (Navigation)>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.File based connectivity.WebHome||target="blank"]]
Carlijn Kokkeler 31.1 58 * [[Advanced (Menu)>>doc:Main.eMagiz Academy.Microlearnings.Advanced Level.WebHome||target="blank"]]
Carlijn Kokkeler 33.1 59 ** [[File based Connectivity (Menu)>>doc:Main.eMagiz Academy.Microlearnings.Advanced Level.File based connectivity.WebHome||target="blank"]]
Erik Bakker 35.1 60 * [[Header Line (Search Result)>>url:https://docs.emagiz.com/bin/view/Main/Search?sort=score&sortOrder=desc&highlight=true&facet=true&r=1&f_space_facet=0%2FMain.&f_type=DOCUMENT&f_locale=en&f_locale=&f_locale=en&text=%22header+line%22||target="blank"]]
Erik Bakker 21.1 61 )))((({{toc/}}))){{/container}}{{/container}}