|
-
April 27th, 2001, 08:37 AM
#1
Reading text file
hi
i am supposed to read a text file and write only particular data it in to a grid.the position of the particular data is being extracted from another file.i am using a textstream for this purpose. the problem here is every time i want to extract data i am opening the file because of which there are many loops. there is any method by which i can optimise my program.
does anybody know about this
thanks
roopa
-
April 28th, 2001, 01:34 AM
#2
Re: Reading text file
you might consider read the file into a string variable for further processing
HTH
cksiow
http://vblib.virtualave.net - share our codes
-
April 28th, 2001, 08:10 AM
#3
Re: Reading text file
hi
The file may consist of more than 100 or even 1000 lines.The data i want may be at a particular line so i don't want to read every line.
bye
-
April 28th, 2001, 08:29 AM
#4
Re: Reading text file
Read the file into an array at startup then search the array whenever you need to update the grid instead of reReading the file.
John G
-
April 28th, 2001, 11:04 AM
#5
Re: Reading text file
Well, the best way to optimize your program has been suggested by John and cksiow, that is reading the data into a string variable. Then do the processing on the string instead of the file.
Reading the file into a string can be done line by line or even the whole file in one shot. Line Input, Input() and Read() should be able to help your reading the data and FileSize() function will return the file size of an opened file (if i'm not mistaken).
Good luck,
-Cool Bizs
Good Luck,
-Cool Bizs
-
April 29th, 2001, 01:20 AM
#6
Re: Reading text file
Hi,
U can open the file using binary acces read method.So,u can open a file at once instead of looping thru line by line.Then,u can use split function for spliting the entire file into at array(Array of strings,ur delemiter of the split function is vbcrlf) and u can erase the array after finishing ur process.It will increase ur performance and reduce the memory load.
umapathy
-
April 30th, 2001, 07:50 PM
#7
Re: Reading text file
Thanks a lot for for your suggestions.
i was able to optimise my program as you told.Though i had thought of using arrays i was not very sure of it.
Thanks
roopa
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|