Announcement

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

  • too many filenames import delimited

    Hello,
    I am using the following code to import around 7000 txt files and I get the error "too many filenames". Any tips?
    Thank you


    local filenames: dir "." files "*.txt"

    tempfile building

    save `building', emptyok
    foreach f of local filenames {
    clear
    set obs 1
    gen filename = "`f'"
    gen strL text = fileread("`f'")
    append using `building'
    save `"`building'"', replace
    }

    use `building', clear

  • #2
    Suppose your filenames start with A, B, C, or D. Then
    Code:
    tempfile building
    save `building', emptyok
    foreach v in A B C D {
        local filenames: dir "." files "`v'*.txt
        foreach f of local filenames {
        ....
        }
    }
    will break the list of 7000 filenames into smaller groups.

    Comment


    • #3
      Well, they start all with A actually :-)

      Comment


      • #4
        Then generalize my advice in post #2 appropriately. Perhaps the second letter is P, Q, R, or S.
        Code:
        tempfile building
        save `building', emptyok
        foreach v in P Q R S {
            local filenames: dir "." files "A`v'*.txt
            foreach f of local filenames {
            ....
            }
        }

        Comment

        Working...
        X