If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Can I replace a line in a text file or start looping from a line in ASP

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-31-09, 03:46
oliflorence oliflorence is offline
Registered User
 
Join Date: Aug 2004
Posts: 96
Can I replace a line in a text file or start looping from a line in ASP

Hi,
i am working on a project where I have to read a .txt file for a feed and parse the data line by line.

I am using FSO in ASP to do this and it is working fine on small versions of the file, unfortunatly, the actual file is massive in size (670,000 kb) and I am not able to interprete the full file.

There is about 200,000 lines in the file of up to 4,000 characters each and i can read the first thousands fine but the problem starts when going further.

Due to the size of the file, I am unable to store it in a variable or array etc to manipulate it, the best way I have found is by looping through the lines and reading them one by one.
I can think of 2 solutions here, I could read a line and then remove it, do this for let say 1000 lines, move out of the file (which is now smaller by 1000 lines) and reaccess it and do the same again. The problem here is that I can't find a way to replace the line, is this possible to do??
I can write a line but it is a new line, it doesn't replace an existing one.

The second idea would be to loop through a number of line, for instance 1000, but only starting starting at line 1001 for instance, this way i could access the file several times. The only way I have found to do this is by using SkipLine but it means I still have to start the loop from the first line and ultimately, it ends crashing the same way.
Is there a way to start at loop at line???

Any pointer would be appreciated.
Reply With Quote
  #2 (permalink)  
Old 07-31-09, 08:54
Ax238 Ax238 is offline
Registered User
 
Join Date: May 2009
Posts: 257
Why not just read the line from one file, do your processing, and then write the line to another file? After you are done, you can save the new file over the old file.

Ax
Reply With Quote
  #3 (permalink)  
Old 07-31-09, 11:23
oliflorence oliflorence is offline
Registered User
 
Join Date: Aug 2004
Posts: 96
Hi,
i am not sure I am following you on this. If i overwrite the existing file without going to the end of it then I am loosing the data?
Reply With Quote
  #4 (permalink)  
Old 08-03-09, 14:00
Ax238 Ax238 is offline
Registered User
 
Join Date: May 2009
Posts: 257
Sorry for the delayed response, but no, that's not what I'm talking about. Maybe this will help:
  1. While there are still lines to process in the file
    1. Read the line from the existing file
    2. Perform necessary processing tasks
    3. Write the line to a new file
  2. Repeat
  3. After all lines have been processed and then saved to the new file, save the new file as the original file if necessary; or just use the new file for whatever you need it

Ax
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On