Forum Discussion

David_Wang's avatar
David_Wang
New Contributor II
7 years ago

How to read file property (modified date, created date)

Hi, I’m building a pipeline to load excel file, looks like the file reader snap can read file property (especially last modified date), but I’m not able to find a solution which can let me save the modified date for later process.
If I try to using excel parser snap in next step, it can change binary data to excel stream, but it will also lose file property which belong to the original file. Has anyone encounter same issue and resolve it without using script snap?

Thanks,
David

7 Replies

    • David_Wang's avatar
      David_Wang
      New Contributor II

      Hi Tlikarish,

      Thanks a lot for your help, this is definitely what I’m looking for, I really appreciate your help and the community.
      It’s still a new tool for me, so a lot of thing need to learn.

      Thanks,
      David

    • David_Wang's avatar
      David_Wang
      New Contributor II

      Hi Tlikarish,

      Just one more question, since snaplogic is case sensitive, when I loading the excel file, it will fail due to excel header using mixed upper and lower case, but actually column name in my destination is full upper case. Mapper can definitely fix it, but if I’m trying to make the pipeline dynamic, and reusable, I will need some method can read the excel header row and upper case the whole header dynamically. If there is not possible being done by regular snap, I will try script. Thanks again.

      Thanks,
      David

      • tlikarish's avatar
        tlikarish
        Employee

        Mapper can definitely fix it, but if I’m trying to make the pipeline dynamic, and reusable, I will need some method can read the excel header row and upper case the whole header dynamically.

        You can use an expression in the mapper like

        $.mapKeys((value, key) => key.toUpperCase())
        

        That should work for any header you want. Here’s more information on the mapKeys function.

        EDIT: In the mapper you’ll want to set the Target Path for that expression to $. Here’s the configuration I used in my test.

  • tstack's avatar
    tstack
    Former Employee

    If you need to make a value available to different snaps of a pipeline, you can use a child pipeline and pass in pipeline parameters with the values of interest. In this case, you can use a DirectoryBrowser snap to get the file metadata and then use a PipelineExecute snap to start the child pipeline and pass it the relevant metadata.

    The following is a screenshot of the parent pipeline showing the PipelineExecute snap that is calling the child and passing in the file path and last update time:

    In the child pipeline, we have a file reader that will read the file passed in by the parent. (I didn’t do anything with the _lastModifiedTime variable)

    Here are the exports of those pipelines:

    FileMetadataParent_2018_10_11.slp (3.9 KB)
    FileMetadataChild_2018_10_11.slp (3.9 KB)

    • David_Wang's avatar
      David_Wang
      New Contributor II

      Hey, your guys are amazing! I just tried same idea right before read your reply. Thanks a ton.