Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • File not found error

    I'm trying to importing several files from a folder using this code:
    cd "\\xyz"

    local aaa: dir . files "*.csv"

    foreach file of local aaa{
    preserve
    insheet using `"`file'"'
    save temp, replace
    restore
    append using temp, force
    }

    I get af "fil not found" error?

    But when import separately using this code there is no error:
    import delimited "\\xyz\filname.csv"

    What could the problem be?

    Kind regards
    Torben


  • #2
    After an initial read through I'm not spotting what would cause the file not found problem. For debugging issues like this I like to use the display command liberally to show me whether my local macros are performing as expected. You also probably want to check to make sure you're ending up in the intended directory and the files you hope to find are there. If you post the results of running the following we might be able to help you figure out what's going on. Post results in code tags to make them readable. Also, see the FAQ for further tips on what info is useful to make it easier for forum folks to answer questions).

    Code:
    cd "\\xyz"
    
    ls
    
    local aaa: dir . files "*.csv"
    
    display `" `aaa' "'
    
    foreach file of local aaa{
       display "`file'"
    }
    You can also use
    Code:
    set tracedepth 1
    set trace on
    That will help pinpoint where in the loop the problem is happening but when I tried it with a created example it did not show me the contents of local aaa , so I prefer manually displaying things in this particular instance.


    Once you fix the issue with the file not found you're going to need add the clear option to your insheet command since you are not starting with an empty dataset the second time through the loop.

    Comment

    Working...
    X