Hitachi Vantara Pentaho Community Forums
Results 1 to 11 of 11

Thread: Last line ?

  1. #1

    Default Last line ?

    Hi,
    I'd like to read the last line of a file and just this one. Is it possible to do this without a Shell ?

    Thx very much.

  2. #2
    Join Date
    Nov 1999
    Posts
    9,729

    Default

    Probably, but it's going to be more complex than "tail -1" :-)

  3. #3
    Join Date
    Oct 2007
    Posts
    15

    Default shell script

    i ran into a similar problem at one stage, in the end I opted for a shell script.

    dan

  4. #4
    Join Date
    Sep 2006
    Posts
    10

    Default

    Have you tried the blocking step?

  5. #5
    Join Date
    Jul 2007
    Posts
    247

    Default

    It's actually quite easy. Since 3.0 GA there's the "Get Files Rows Count" step which gets you the number of rows in a file.

    Use this step in combination with a textfile input and check the "Rownum in output" option. This gets you the number of each line in an extra field.

    What comes next, right - use a merge join to get your last line. See the sample attached for details (just preview the dummy step).

    Note: if your last line doesn't include a closing carriage return you might have to add +1 to your number of rows using the calculator step or something like that.

    Regards,
    Ben
    Attached Files Attached Files

  6. #6
    Join Date
    Oct 2007
    Posts
    15

    Default

    sounds like a good idea!

  7. #7

    Default Thank you

    Hi,
    Thanks all for your answers...
    In fact, I'm using 2.5.0 so I can't use the "Rownum in output".
    I finaly wrote a shell script to solve the problem I had.

  8. #8
    Join Date
    Sep 2006
    Posts
    10

    Default

    If you just need to read the last line, just use a "text file input" step, then add a "blocking" step, you will get the last row. It's easy and you don't need a shell script.

  9. #9

    Default

    Hi, this blocking step works fine !
    I didn't think of it... But I also had to count the lines of my file so I get it with two lines of shell script.
    But thanks very much for your answer, I will know it for next time.

    anaïs

  10. #10
    Join Date
    Sep 2006
    Posts
    10

    Default

    Once again, no need for shell script!

    Just check the "rownum in output" option on the textfile input" step, you should be able to get the rownum as well.

  11. #11

    Question Row Count

    Dear Friends,

    I am also trying to find the number of records thats written in a file.

    I looked at the example that Ben provided, tried to include couple of steps in my transformation, still couldn't get it to work.

    I am trying to make it work with a simple example.

    Table read (three columns) -> Text File output (all the colulmns).

    I have few other reports to run like this and at the end of all transformation, I am trying to send a status email with number of records in each output file.

    Could you please advise how I can get the record count for each file?

    Any help would be appreciated.

    Thanks again,
    Mani

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.