<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Apache Nifi - Transform Fixed Width File into Delimited File? in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Transform-Fixed-Width-File-into-Delimited-File/m-p/329420#M230454</link>
    <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/92931"&gt;@AnnaBea&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Let me make sure I am clear on your ask here:&lt;BR /&gt;&lt;BR /&gt;1. You have successfully split your source file in to 3 parts (header line, body line(s), and footer line).&lt;BR /&gt;2. You have successfully modified all three split files as needed.&lt;BR /&gt;3. You are having issues re-assembling the three split files back in to one file in order of header, body, footer using MergeRecord processor?&lt;BR /&gt;&lt;BR /&gt;With this particular dataflow design, the MergeRecord processor is not likely what you want to use.&amp;nbsp; You probably want to be using the MergeContent processor instead with a "&lt;STRONG&gt;Merge Strategy&lt;/STRONG&gt;" of&amp;nbsp; "&lt;STRONG&gt;Defragment&lt;/STRONG&gt;".&amp;nbsp; But to get these three source FlowFiles merged in a specific order would require some additional work in your upstream flow.&amp;nbsp; In order to use "Defragment" your three source FlowFiles all would need o have these FlowFile Attributes:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;fragment.identifier&lt;/TD&gt;&lt;TD&gt;All split FlowFiles produced from the same parent FlowFile will have the same randomly generated UUID added for this attribute&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;fragment.index&lt;/TD&gt;&lt;TD&gt;A one-up number that indicates the ordering of the split FlowFiles that were created from a single parent FlowFile&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;fragment.count&lt;/TD&gt;&lt;TD&gt;The number of split FlowFiles generated from the parent FlowFile&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Add one UpdateAttribute processor before your RouteText and configure it to create the "fragement.identifier" attribute with a value of "&lt;SPAN&gt;${UUID()}" and another Attribute "Fragment.count" with a value of "3".&amp;nbsp; Each FlowFIle produced by RouteText should then have these two attribute set on it.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2. Then add one UpdateAttribute processor to each of teh 3 flow paths to set the "fragment.index" attribute uniquely per each dataflow path.&amp;nbsp; value=1 for header, value=2 for body, and value=3 for footer.&lt;BR /&gt;3. Now the MergeContent will have what it needs to bin these three files by the UUID and merge them in the proper order.&lt;BR /&gt;&lt;BR /&gt;There are often times many ways to solve the same use case using NiFi components.&amp;nbsp; Some design choices are better than others and use less resources to accomplish the end goal.&lt;BR /&gt;&lt;BR /&gt;While above is one solution, there are others I am sure.&amp;nbsp; Cloudera's professional services is a great resource that can help with use case designs.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;If you found this response assisted with your query, please take a moment to login and click on "&lt;STRONG&gt;Accept as Solution&lt;/STRONG&gt;" below this post.&lt;BR /&gt;&lt;BR /&gt;Thank you,&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;</description>
    <pubDate>Tue, 02 Nov 2021 15:23:49 GMT</pubDate>
    <dc:creator>MattWho</dc:creator>
    <dc:date>2021-11-02T15:23:49Z</dc:date>
    <item>
      <title>Apache Nifi - Transform Fixed Width File into Delimited File?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Transform-Fixed-Width-File-into-Delimited-File/m-p/328773#M230328</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm new to Nifi and struggling with what seems like a simple task.&lt;/P&gt;&lt;P&gt;I have a file with Header, Body and Trailer in fixed width layout.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="file.PNG" style="width: 999px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/32736i52399E2A6EA70DCD/image-size/large?v=v2&amp;amp;px=999" role="button" title="file.PNG" alt="file.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The header record always starts with an A;&lt;/P&gt;&lt;P&gt;The Trailer record always starts with a Z;&lt;/P&gt;&lt;P&gt;Body records are identified by B, C, D and so on... (except A and Z)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I first used Route Text to separate Header, Body and Trailer, because my goal here was to replace the fixed width with a delimiter (;) so I can make sense of the info in the file (header, body and trailer will have a different number of columns when separated by a delimiter).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I used ReplaceText with a regex to create columns delimited by semi colon instead of fixed width.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I need to regroup the rows and create a single file again, with the header, body and trailer, but this time all separated by semi colons. This is what I'd like to achieve:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FILE2.PNG" style="width: 999px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/32737iF46FE06C1889C942/image-size/large?v=v2&amp;amp;px=999" role="button" title="FILE2.PNG" alt="FILE2.PNG" /&gt;&lt;/span&gt;My template looks like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="flow.PNG" style="width: 999px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/32738i5F3F06529C056AA0/image-size/large?v=v2&amp;amp;px=999" role="button" title="flow.PNG" alt="flow.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is that possible? I tried using MergeRecord for that but I really don't know how to configure its properties, and it's not merging anything.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 12:53:26 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Transform-Fixed-Width-File-into-Delimited-File/m-p/328773#M230328</guid>
      <dc:creator>AnnaBea</dc:creator>
      <dc:date>2021-10-25T12:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Nifi - Transform Fixed Width File into Delimited File?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Transform-Fixed-Width-File-into-Delimited-File/m-p/329420#M230454</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/92931"&gt;@AnnaBea&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Let me make sure I am clear on your ask here:&lt;BR /&gt;&lt;BR /&gt;1. You have successfully split your source file in to 3 parts (header line, body line(s), and footer line).&lt;BR /&gt;2. You have successfully modified all three split files as needed.&lt;BR /&gt;3. You are having issues re-assembling the three split files back in to one file in order of header, body, footer using MergeRecord processor?&lt;BR /&gt;&lt;BR /&gt;With this particular dataflow design, the MergeRecord processor is not likely what you want to use.&amp;nbsp; You probably want to be using the MergeContent processor instead with a "&lt;STRONG&gt;Merge Strategy&lt;/STRONG&gt;" of&amp;nbsp; "&lt;STRONG&gt;Defragment&lt;/STRONG&gt;".&amp;nbsp; But to get these three source FlowFiles merged in a specific order would require some additional work in your upstream flow.&amp;nbsp; In order to use "Defragment" your three source FlowFiles all would need o have these FlowFile Attributes:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;fragment.identifier&lt;/TD&gt;&lt;TD&gt;All split FlowFiles produced from the same parent FlowFile will have the same randomly generated UUID added for this attribute&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;fragment.index&lt;/TD&gt;&lt;TD&gt;A one-up number that indicates the ordering of the split FlowFiles that were created from a single parent FlowFile&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;fragment.count&lt;/TD&gt;&lt;TD&gt;The number of split FlowFiles generated from the parent FlowFile&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Add one UpdateAttribute processor before your RouteText and configure it to create the "fragement.identifier" attribute with a value of "&lt;SPAN&gt;${UUID()}" and another Attribute "Fragment.count" with a value of "3".&amp;nbsp; Each FlowFIle produced by RouteText should then have these two attribute set on it.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2. Then add one UpdateAttribute processor to each of teh 3 flow paths to set the "fragment.index" attribute uniquely per each dataflow path.&amp;nbsp; value=1 for header, value=2 for body, and value=3 for footer.&lt;BR /&gt;3. Now the MergeContent will have what it needs to bin these three files by the UUID and merge them in the proper order.&lt;BR /&gt;&lt;BR /&gt;There are often times many ways to solve the same use case using NiFi components.&amp;nbsp; Some design choices are better than others and use less resources to accomplish the end goal.&lt;BR /&gt;&lt;BR /&gt;While above is one solution, there are others I am sure.&amp;nbsp; Cloudera's professional services is a great resource that can help with use case designs.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;If you found this response assisted with your query, please take a moment to login and click on "&lt;STRONG&gt;Accept as Solution&lt;/STRONG&gt;" below this post.&lt;BR /&gt;&lt;BR /&gt;Thank you,&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;</description>
      <pubDate>Tue, 02 Nov 2021 15:23:49 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Apache-Nifi-Transform-Fixed-Width-File-into-Delimited-File/m-p/329420#M230454</guid>
      <dc:creator>MattWho</dc:creator>
      <dc:date>2021-11-02T15:23:49Z</dc:date>
    </item>
  </channel>
</rss>

