Hitachi Vantara Pentaho Community Forums
Results 1 to 6 of 6

Thread: Text File Input - Timestamp

  1. #1
    Join Date
    Jan 2006
    Posts
    25

    Default Text File Input - Timestamp

    One of the nice feature in Text File Input is the ability to extract file and record level information (File name and record number) using the content tab. What is surprisingly missing is the ability to extract the timestamp. Other than using the 'Get files from result' which I have read on the forum as one of the means to extract the timestamp is there any other way to get this information using the Text File Input?

  2. #2
    Join Date
    May 2006
    Posts
    4,882

    Default

    No not right now.
    Sven

  3. #3
    Join Date
    Jan 2006
    Posts
    25

    Default

    For anyone who needs this, I created a simple modjs step with the following logic:

    var fsManager = Packages.org.apache.commons.vfs.VFS.getManager();
    var filePath = getEnvironmentVar("Internal.Transformation.Filename.Directory")
    var zipFile = fsManager.resolveFile("zip:" + filePath + "/sample.zip");
    var children = zipFile.getChildren();
    for (var i = 0; i < children.length; i++)
    {
    Alert(children[i].getContent().getLastModifiedTime());
    }

    This will give the timestamp. This can be implemented as a method in the TextFileInput. This may not be the best way to do this, but the quickest that I could come up with my limited capabilities. Feel free to modify as needed. Note: This is for extracting the timestamps of individual files within a Zip file.

  4. #4
    Join Date
    May 2006
    Posts
    4,882

    Default

    Javascript to the rescue

  5. #5
    Join Date
    Jan 2006
    Posts
    25

    Default

    Yes, the possibilities are endless. In reality this could really be added as a function to the Text File Input step where the GUI can have a checkbox that allows the users to select the timestamp of a file. Just like it currently allows you to select the File Name as one of the columns.

  6. #6
    Join Date
    May 2006
    Posts
    4,882

    Default

    You can make a tracker for it. Personally I don't see a really wide use for it. If you want to check on the file timestamp you could use e.g. get files in another transformation to determine whether or not to process the file depending on the timestamp.
    If you add timestamp like you want to, you would duplicate it in every row being created. And if you have it for text input, why not for excel input e.g.

    Regards,
    Sven

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.