We recommend switching to the latest versions of Edge, Firefox, Chrome or Safari. Using Internet Explorer will result in a loss of website functionality.

Read a directory and set variables?

Comments

7 comments

  • Avatar
    Infogix Support
    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]
    0
    Comment actions Permalink
  • Avatar
    Infogix Support
    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
    0
    Comment actions Permalink
  • Avatar
    Infogix Support
    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.
    0
    Comment actions Permalink
  • Avatar
    Infogix Support
    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
    0
    Comment actions Permalink
  • Avatar
    Infogix Support
    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.
    0
    Comment actions Permalink
  • Avatar
    Infogix Support
    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?
    0
    Comment actions Permalink
  • Avatar
    Infogix Support
    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)
    0
    Comment actions Permalink

Please sign in to leave a comment.