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

Naming Output Files Using Data in Graph

  • 1.  Naming Output Files Using Data in Graph

    Employee
    Posted 10-14-2008 15:52

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

    Originally posted by: Jonser1246

    I have used the directory node to bring a group of files into a graph. These files have long time stamps at the end of the shared (root) file name. I can then organize these files based on the order in which they were created and then run them through the graph.

    The problem is that I need to reapply that original timestamp to the filename when it outputs. I can generate the exact path and filename in the graph, but there are no output files that let me name via a record reference like the CSV File input node.

    Any ideas?


  • 2.  RE: Naming Output Files Using Data in Graph

    Employee
    Posted 10-16-2008 14:40

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

    Originally posted by: rboccuzzi

    Not sure if this would work for you, but you could name the file in an standard outfile node and then do a rename using the data that is processed, using the BRAINscript function moveFile. Does this do what you want?

    $Rich


  • 3.  RE: Naming Output Files Using Data in Graph

    Employee
    Posted 10-16-2008 18:43

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

    Originally posted by: Jonser1246

    What type of node does this happen in?


  • 4.  RE: Naming Output Files Using Data in Graph

    Employee
    Posted 10-16-2008 18:51

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

    Originally posted by: ltolleson

    Are you using BRAIN 3.x or BRAIN 4.x?


  • 5.  RE: Naming Output Files Using Data in Graph

    Employee
    Posted 10-16-2008 19:03

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

    Originally posted by: Jonser1246

    4.x


  • 6.  RE: Naming Output Files Using Data in Graph

    Employee
    Posted 10-16-2008 19:11

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

    Originally posted by: ltolleson

    You can do this in a filter node. The node will need the input containing the information needed for the filename, so connect the output from the node with the data to a filter node. If the input has multiple records, then you will need to construct an "IF" statement in the node to limit the node to a single execution since the filter node executes once for each record in the input. Use the following code in a filter node to execute the moveFile command only once.

    if firstExec then
    moveFile(oldFileName, newFileName)

    The function firstExec is only TRUE for the very first record, so this limits the execution of moveFile to one time.

    The parameter newFileName can be constructed from any data in the first record.

    Hope this helps...

    Larry


  • 7.  RE: Naming Output Files Using Data in Graph

    Employee
    Posted 10-16-2008 20:30

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

    Originally posted by: Jonser1246

    To clarify -

    In one output I have a single record which is the name I want to apply to the data, which is coming from a second output.

    I'm not seeing how I can get the name joined to the information with the strategy you suggest here. Then again Im new to this program...


  • 8.  RE: Naming Output Files Using Data in Graph

    Employee
    Posted 10-17-2008 13:43

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

    Originally posted by: rboccuzzi

    It sounds like you would want to put the output which contains the data to an output file, like Output Delimited. You would give this file a known name, something constant. Then you would have a filter attached to the other output, and you would "clock" the filter to run after the Output Delimited node. The filter node could then move the file from the known name to the new name based on the data from it's input stream. Does this make sense? I can attach a short graph showing this if you need.

    $Rich


  • 9.  RE: Naming Output Files Using Data in Graph

    Employee
    Posted 10-17-2008 14:37

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

    Originally posted by: Jonser1246

    This makes sense. The syntax is hanging me up though. Suppose I have the data file that I save to C:/Work/ as "1.txt"

    Then I have my new name which is the "FileName" input coming into the filter.

    would my syntax within the node then be:

    if firstExec then
    moveFile ('C:/Work/1.txt', 'FileName') ?

    also should 'FileName' contain the whole path as well?

    Post edited by: Jonser1246, at: 2008/10/17 16:47<br><br>Post edited by: Jonser1246, at: 2008/10/17 16:48


  • 10.  RE: Naming Output Files Using Data in Graph

    Employee
    Posted 10-17-2008 15:31

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

    Originally posted by: rboccuzzi

    You are mixing strings and column values, which is probably your confusion. The name of the existing file is a string constant, so should be "C:/Work/1.txt" (double quotes, not single quotes). the field with the new name is a field, so should be either single quotes 'FileName' or if it doesn't have spaces or funny characters, you can just use as FileName (no quotes).


  • 11.  RE: Naming Output Files Using Data in Graph

    Employee
    Posted 10-17-2008 18:50

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

    Originally posted by: Jonser1246

    Thanks for the help. It worked beautifully =)