Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-10996

CSV output with header - but always, even for 0 record flowfiles

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 1.20.0
    • Core Framework

    Description

      We use a “ConvertRecord” processor where we convert an AVRO to a CSV. For that CSV output we would like to have the header enabled, so we tried to set “Include Header Line – true” for the Controller Service of the CSVRecordSetWriter. The issue is, if we have zero records, the header doesn’t show up (but it was there of course in the AVRO file). We need to have it as the columns are important for us, even if we have 0 records.

      At the moment we solve it with an extra ExecuteScript processor just before the ConvertRecord, there we add always an extra record with the header lines as string. But it feels a bit hacky as the record.count attribute is 1 record too high (due to the fake header record).

      Comment from joewitt from users mailinglist: "Makes sense what you're looking for.  Just not sure where this 'concern' would live whether it is in the processors themselves or the controller services for the writers."

      It seems that I'm not alone with that requirement, at least one other person (Jens M. Kofoed) uses a similar workaround.

      Attachments

        1. NiFi_CSV_header_true.png
          87 kB
          Josef Zahner

        Issue Links

          Activity

            People

              mattyb149 Matt Burgess
              jzahner Josef Zahner
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m