Results 1 to 9 of 9

Thread: Read a directory and set variables?

  1. #1

    Question Read a directory and set variables?

    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. #2
    Lavastorm Employee stonysmith's Avatar
    Join Date
    Nov 2006
    Location
    Grapevine Tx
    Posts
    799

    Default

    Following the migration of the Lavastorm support system to the Infogix support system all questions on LAE and questions about migrating to Data3Sixty® Analyze should be posted on the new community forum.

    You can access the Infogix support portal, which covers all Infogix products, here:

    https://support.infogix.com/hc/en-us

    To post a question follow the Community link from there to view the LAE community topics. Alternatively, you can go directly to the LAE Community topics using the following link:
    https://support.infogix.com/hc/en-us...0001073653-LAE

  3. #3
    Lavastorm Employee stonysmith's Avatar
    Join Date
    Nov 2006
    Location
    Grapevine Tx
    Posts
    799

    Default

    Use the DirectoryList node to get a list of filenames.

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

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

  4. #4

    Default

    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

  5. #5
    Lavastorm Employee stonysmith's Avatar
    Join Date
    Nov 2006
    Location
    Grapevine Tx
    Posts
    799

    Default

    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.

  6. #6

    Default

    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

  7. #7
    Lavastorm Employee stonysmith's Avatar
    Join Date
    Nov 2006
    Location
    Grapevine Tx
    Posts
    799

    Default

    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.

  8. #8

    Default

    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?

  9. #9
    Lavastorm Employee stonysmith's Avatar
    Join Date
    Nov 2006
    Location
    Grapevine Tx
    Posts
    799

    Default

    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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •