Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

Importing Text Files

Discussion in 'Information Technology' started by Claude, Nov 2, 2005.

  1. Claude

    Claude
    Expand Collapse
    Guest

    I have a problem where I need to import a host of different text files from
    a directory where the file names are not consistently the same. I know how
    to do it no problem when I know the name but how do you do it when you
    don't know the name? Thanks in advance.

    Claude.
     
  2. Loading...

    Similar Threads Forum Date
    Malaysia Hindus, Sikhs In Malaysia Appalled With University Textbook Ridiculing Their Faiths Breaking News Jun 14, 2016
    Hard Talk Taking One Liners Out Of Context From Gurbani To Allow Intellectual Independence? Hard Talk Apr 23, 2016
    India Protests in India Over the Desecration of a Holy Text Leave Two Dead Breaking News Oct 16, 2015
    Learn Punjabi Convert Punjabi text Language, Arts & Culture Oct 11, 2013
    Sikh Coalition Harmeet Kaur Took the Lead ! First to Respond to Textbook Challenge ! Sikh Organisations May 25, 2013

  3. xRoachx

    xRoachx
    Expand Collapse
    Guest

    Here is a simple function that will loop through a specified directory
    looking for the specified file type. You may need to make adjustments
    depending on the type of text file you have (delimited or fixed) but this
    should get you started:

    Function fImportAllFiles()

    Dim strfile As String
    Dim strPath As String

    'File path to the Text files
    '
    strPath = "PATH TO YOUR FILES"

    'Change the default directory to the file path
    '
    ChDir strPath

    'Find the first Text file to use to create a string
    '
    strfile = Dir("*.txt")

    'Loop through the string & import
    '
    Do While Len(strfile) > 0

    DoCmd.TransferText acImportFixed, , "TABLE NAME"

    'delete the file (consider moving it to an Archive folder instead.)
    'Kill strPath & "/" & strfile

    'Call Dir to get the next file
    '
    strfile = Dir
    Loop

    End Function

    "Claude" wrote:

    > I have a problem where I need to import a host of different text files from
    > a directory where the file names are not consistently the same. I know how
    > to do it no problem when I know the name but how do you do it when you
    > don't know the name? Thanks in advance.
    >
    > Claude.
    >
     
  4. Claude

    Claude
    Expand Collapse
    Guest

    Thank you very much. It looks perfect! I'll let you know how it goes.

    Claude.
     
  5. Claude

    Claude
    Expand Collapse
    Guest

    Any idea why it always defaults to my My Documents directory? Otherwise its
    working perfect. Thanks again.

    Claude

    "=?Utf-8?B?eFJvYWNoeA==?=" <xRoachx@discussions.microsoft.com> wrote in
    news:8103DB14-2F9D-47DC-8268-DE7CF0F74DE3@microsoft.com:

    > Here is a simple function that will loop through a specified directory
    > looking for the specified file type. You may need to make adjustments
    > depending on the type of text file you have (delimited or fixed) but
    > this should get you started:
    >
    > Function fImportAllFiles()


    >>
     
  6. Claude

    Claude
    Expand Collapse
    Guest

    hehe never mind - stupid me. Figured it out. Thanks!
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page