Results 1 to 7 of 7

Thread: reading the contents of a text file

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224
    Hi guys
    I have the following function that reads the contents of one of my files. However, I have hundreds of files that I want to read individually. How do I put all the .txt files that I have in my folder into an array and put them through this function????
    Thanks for any help.
    JK

    Code:
    Public Function Opening_Files_For_Reading()
    Dim inputfile  As String
    inputfile = "D:\Orator\Outgone\00007629000003.txt"
    '***************************************'
    'Input the file ----  into a string named TempFile'
    '***************************************'
    TempFile = ""   'initialise tempfile
    Open inputfile For Input As #1
        Do While Not EOF(1) ' Check for end of file.
            Line Input #1, GenFileText   ' Read line of data.
            TempFile = TempFile & GenFileText 'increment the temporary string with the file data
            MsgBox GenFileText
        Loop
    
    Close #1
    
    End Function

  2. #2
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    Heh, yeah. I was looking at my code. but he asked for an array, so I gave it to him Though you could easily just slap in the text file parsing code in the for ... each loop with minimal problems. I do have to admit that I hadn't tested my code ... but I think it'll work
    -Excalibur

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224

    Smile Cheers guys

    Thanks a lot for the help guys.
    paulw, what I'm trying to do when I finish here is pass the file contents into a parsing routine which will send the data up to a database.




  4. #4
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    You might be more efficient if you open up the database connection and read the data in in one go. If the files are small, there may well be several in the buffer.

    Cheers,

    Paul.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224
    Thanks a lot for the input.
    There are several hundered files in the folders and what I need to do is actually place a timestamp on each file that I parse in order to eliminate the possibility to duplictes in the database.
    Any suggestions on how I might do this, more efficiently??
    Thanks again,
    Your help is really appreciated
    JK

  6. #6
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  7. #7
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    ...and to get it:

    MsgBox FileDateTime("MYFILE")
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

Posting Permissions

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



Click Here to Expand Forum to Full Width