Hitachi Vantara Pentaho Community Forums
Results 1 to 8 of 8

Thread: Text file output does not generate header when table input return 0 row

  1. #1
    Join Date
    Aug 2017
    Posts
    3

    Default Text file output does not generate header when table input return 0 row

    Hello all,

    Using Kettle 4.4.0, I have a Transformation which includes: a Table input --> Text file output
    In the Text file output I have checked 'Header' in Content tab
    I expected that the output file always has header row despite of the result from 'Table input',
    but actually the header only exported when Table input returns 1 ore more rows.
    Could any one help me to always have header in the exported file.

    Best,

  2. #2
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    Text-File-Output will only write a header when seeing the first data row.
    So long, and thanks for all the fish.

  3. #3
    Join Date
    Aug 2017
    Posts
    15

    Default

    Marabu is right. If you really need your header even with an empty file, you can use the Detect empty stream step, recreate your header and go to output

  4. #4
    Join Date
    Aug 2017
    Posts
    3

    Default

    Thank RobinB, marabu

    I tried with Detect empty stream, however beside headers it generate an empty row as well.
    Since I expect only header row in-case no data rows return I tried the following option and it works well.
    1. Add a Generate Rows step to generate header
    2. Add Prioritize Streams step to receive output from both Generate Rows step (1st) and Table input step (2nd)
    3. Text file output receives output of Prioritize Streams to generate csv file (since header row are manually generated, i leave option Header of Text file output un-checked)

    Many thanks for your help.
    Name:  CVSHeaders.gif
Views: 1958
Size:  6.6 KB


  5. #5
    Join Date
    Apr 2008
    Posts
    4,696

    Default

    Your solution will only work if all columns are string. If they are not, PDI will complain that the field layout is not the same.

  6. #6
    Join Date
    Aug 2017
    Posts
    3

    Default

    it is lucky that my data is all string and exported csv file does not require any special format.
    Quote Originally Posted by gutlez View Post
    Your solution will only work if all columns are string. If they are not, PDI will complain that the field layout is not the same.

  7. #7

    Default

    Hello All,

    Me too have same issue. I am using a metadata injection step to export table data to text files.
    I used "Detect empty stream" step earlier to export empty tables but it adding a empty row as well.

    Am looking for solution to write file with only Header if table has no data. I have multiple files to write dynamically.

    Can anybody help me with this. Thanks.

  8. #8

    Default headers with no input row

    Quote Originally Posted by chetanchavan1126 View Post
    Hello All,

    Me too have same issue. I am using a metadata injection step to export table data to text files.
    I used "Detect empty stream" step earlier to export empty tables but it adding a empty row as well.

    Am looking for solution to write file with only Header if table has no data. I have multiple files to write dynamically.

    Can anybody help me with this. Thanks.

    Did anyone got a solution for this?
    Regards,
    Dileep
    Mail ID

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.