LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Opening a file where directory and file name change

    Employee
    Posted 06-08-2010 15:45

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: TheBishop

    Hi,

    I am trying to open a file where both the directory name and the file name have the year and month of the file, the filename also has a non-predicatable element at the end e.g C:\DirectoryName\201005\AFileName201005RandomElement.txt

    As I am trying to set up a dozen or two of these files I would rather not go through and update them all each month manually, if it weren't for the random element I could use FilenameExpr in the CSV node or if it didn't change directory I could use the Directory List node to get the file name.

    Can anyone help?

    Cheers,

    Bishop


  • 2.  RE: Opening a file where directory and file name change

    Employee
    Posted 06-09-2010 05:57

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: timonk

    Bishop,

    Good Day.

    I think the key to your solution lies in the mechanic of parameter substitution. Remember that you can use BRAINScript parameter textual substitution to setup many nodes that can be altered by only changing the value of the root parameter.

    For example:

    node:Directory_List
    bretype:core::Directory List
    editor:sortkey=4c0f8c8612442580
    output:@40fd2c747c2b1c0a/=
    prop:DirectoryName=c:\temp\{{^DATE^}}
    prop:Pattern={{^DATE^}}DATAFILE*.txt
    editor:XY=280,380
    end:Directory_List


    The code above is a Directory List node, which you are aware of. This node has the benefit of taking standard wildcards as well as parameters.

    In my graph I declared a graph parameter DATE. Then I setup test files: "20100609DATAFILEasefes.txt" and "20100610DATAFILE12345.txt" in the directories "20100609", "20100610". Using the node above, and plugging in the date value into the graph parameter, the Directory List node produced the correct test file. BRAINSscript substituted in the DATE value, and the node took the wildcard * to handle the random element. I then linked it to the .CSV node and used FilenameExpr to load the data (just use the name of the field from the Directory List output:'FileName').

    This is, I think, one possible solution to your situation.

    Regards
    Timon Koufopoulos
    MDA Support.


  • 3.  RE: Opening a file where directory and file name change

    Employee
    Posted 06-09-2010 07:08

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: rboccuzzi

    In addition, the Directory List node can take a directory and perform a recursive traversal. So in this case, you could give the path for the directory as:
    C:\DirectoryName
    and enable the "Recurse" Parameter. After that, you can put a sort and filter node to examine the results found, and choose the latest directory, latest files in the directory, or any other complicated choosing logic you wish to implement.

    Cheers
    Rich


  • 4.  RE: Opening a file where directory and file name change

    Employee
    Posted 06-09-2010 20:54

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: TheBishop

    Thanks Rich and Timon, I have gone with Timon's solution and it is working perfectly, setting the graph parameter has opened up solutions to other road blocks I could see coming up