Hitachi Vantara Pentaho Community Forums
Results 1 to 3 of 3

Thread: Extract single file name using regex - Text file input

  1. #1
    Join Date
    Apr 2015
    Posts
    18

    Default Extract single file name using regex - Text file input

    I am looking for a way using regex to pull only a single file name out of a folder using the text file input step. Example:
    Folder
    File(1).txt
    File(2).txt
    File(3).txt
    It doesn't necessarily matter which file name gets pulled, but I need to pull only one file name. I won't know the file names in advance, so I will have to work with a variable. So far I've tried using [^\]*$, but that pulls all three file names.

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

    Default

    Text File Input isn't designed to allow you to limit to one file (the idea is to process all files of a type)
    Workaround: Use a Get File Names step (Include Row Numbers in output), connected to a filter rows (Only allow rows with RowNum =1), and then feed that to the Text File Input (Filename from field)

  3. #3
    Join Date
    Apr 2015
    Posts
    18

    Default

    Thank you! This worked perfectly for what we needed to do. I appreciate your help!

Tags for this Thread

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.