Hitachi Vantara Pentaho Community Forums
Results 1 to 5 of 5

Thread: How to Check whether the file contain today's date as extn or not?

  1. #1
    Join Date
    Sep 2005
    Posts
    1,403

    Default How to Check whether the file contain today

    Hi


    We are working with “KETTLE”, we have a query



    We have a source file which will store with the extn of today’s date (mmddyyyy) Ex: BL_05152006. Our task is we have to check whether the file contain today’s date as extn or not? Is it possible with “KETTLE”? Please reply ASAP.

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

    Default RE: How to Check whether the file contain today

    Sure, you can add the filename to the output of Text File Input.



    In my usecase example, the filename field contains: C:\Documents and Settings\Matt\Bureaublad\test-stuff\file1_20060515.txt

    So to see whether or not the line of data from a certain file is from today:



    <pre>
    var datepart = filename.Clone().rightstr(12).substr(0,8);

    var today = new Date();

    var todaystr = ""+(today.getFullYear()*10000+(today.getMonth()+1)*100+today.getDate());

    var fileFromToday="N";
    if (datepart.getString().equals(todaystr))
    {
    fileFromToday="Y"
    }
    </pre>


    HTH,



    Matt

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

    Default RE: I Want to pick a file which contains today's date in its name

    (Posted by AC, changed to plain format)

    Hi Matt,


    The given Code will check that the file have today&#39;s date in its name, but my requirment is

    1)I have a folder called CURRENT in that there are several files, from those files i have to pick a file which contain today&#39;s date in its name(I wont pass the file name to Kettle it has to pick up based on date).


    2)Plese send me a code which will check the date in mmddyyyy formate, my source file is like "file1_05172006"

    Thanks & Regards
    Sas

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

    Default RE: I Want to pick a file which contains today's date in its name

    At the moment you can&#39;t do that. You need a piece of script surrounding the transformation.
    (like most warehouses do)

    However, we&#39;re working on that and should have a solution before 2.3.0 gets out in a couple of weeks.

    All the best,

    Matt

  5. #5
    Join Date
    Sep 2005
    Posts
    1,403

    Default RE: I Want to pick a file which contains today's date in its name

    Hi Matt,

    Now we are using Kettle2.3.0, I didn&#39;t find any solution for my requirment.

    Please let me know if is there any other way to do this.

    Thanks

    Sas

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.