LAE

 View Only
  • 1.  Read a directory and set variables?

    Employee
    Posted 05-09-2019 07:09

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

    Originally posted by: StaticFX

    New to Lavastorm

    Wondering if there is a way to do this..

    I have a directory with some files..
    most of the file names dont change so thats easy..
    a few change part of the name each day

    is there a way to scan each file name, then split apart the filename to then set a variable (or somehow set that as the file to import?)

    ImportFile_Modified_xxxxxxxxx.csv

    So I need to:
    Scan the directory
    When it finds a file with partial name "ImportFile_Modified_" grabs it and then remembers the number
    Imports that file
    Creates a directory using that number
    Outputs a file using that number

    lol is it possible?


    Thanks!


  • 2.  RE: Read a directory and set variables?

    Employee
    Posted 05-09-2019 07:39

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

    Originally posted by: stonysmith

    Use the DirectoryList node to get a list of filenames.

    Then, this code will help. It'll work thru the year 2100 <grin>

    FileDate=Filename.replace(".csv","").split("_20")[1]


  • 3.  RE: Read a directory and set variables?

    Employee
    Posted 05-09-2019 08:01

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

    Originally posted by: StaticFX

    im "newer" than that... lol

    I have the Directory List node.. set the path.. I see my file list. (some xlsx, 1 csv)
    I pass (connect) the Dir list to a csv file import..

    So how do i "read" the list and pull that csv from the list
    then, is there a way to set a Run Param to the Num split out?

    if it were vb...

    Dim tmp as string
    Dim fsplit() as string
    Dim fNum as string
    tmp = Dir(path)
    do while tmp <> ""
    if left(tmp)="WIN_APF" and instr(tmp,".csv")<>0 Then
    fsplit=split(replace(tmp,".csv",""),"_")
    fNum = fsplit(Ubound(fsplit))
    exit do
    end if
    tmp=dir
    Loop

    looks for the csv file with WIN_APF
    finds it splits it up
    grabs the number off the file

    sets that number to a global variable


    get it? lol


  • 4.  RE: Read a directory and set variables?

    Employee
    Posted 05-09-2019 08:40

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

    Originally posted by: stonysmith

    Well.. you can do all of that EXCEPT the final step of using it as a global variable (LAE parameter)
    At this time, LAE has no way to convert a row/column data element into a parameter that can be used elsewhere.
    The best you can do is make it an output column and carry it along with the rest of the data.


  • 5.  RE: Read a directory and set variables?

    Employee
    Posted 05-09-2019 09:55

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

    Originally posted by: StaticFX

    ok. thanks...

    So.. How do I tell the CSV file node the filename?

    i did a directory node and set the pattern to *.csv so the output is just one path with filename..
    How do I tell the csv node to take that as the file?
    I tried just leaving it blank. nope


  • 6.  RE: Read a directory and set variables?

    Employee
    Posted 05-09-2019 11:31

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

    Originally posted by: stonysmith

    Leave the top field blank
    put 'FileName' into the second box.


    The top box is for hard-coded names
    the second box is how you get the file from a column of data.


  • 7.  RE: Read a directory and set variables?

    Employee
    Posted 05-09-2019 11:52

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

    Originally posted by: StaticFX

    I found that.. I was trying to figure out how to only load one of the listed files...
    I put a filter node beforehand and set columns for each file (matching patterns)

    Is there a better way to do it?


  • 8.  RE: Read a directory and set variables?

    Employee
    Posted 05-09-2019 12:01

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

    Originally posted by: stonysmith

    One common thing is to sort the list by the date that you've extracted, and then use the TAIL node to take the last record (so as to get the most recent one)