Find a last sentence in a file

Results 1 to 2 of 2

Thread: Find a last sentence in a file

  1. #1
    Join Date
    Dec 1969

    Default Find a last sentence in a file

    Kindly tell me How to read Bottom line/sentence from a text file becos the file size is too big so read the file from starting take much time. pls suggest me. Thankyou

  2. #2
    Join Date
    Dec 1969

    Default You can't really read a file backwards. You..

    ...can skip a certain chunk of the file though (I think there&#039;s a seek method in the FSO, but I&#039;m not sure) and then read from there on. If you then make the assumption that no sentence is going to be larger than, say, 200 characters (bytes), then all you need to do is skip to the end of the file minus 200 bytes and read that little chunk into memory. Then you can extract the last sentence quite easily.<BR><BR>That means though that if a sentence is longer than 200 characters, it won&#039;t work and you&#039;ll chop off the sentence. You could, of course, check if this is the case and then try again and increase the amount of characters you read in until you&#039;ve got the last sentence.<BR><BR>Oliver.

Posting Permissions

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