| | |
Can I replace a line in a text file or start looping from a line in ASP
Please support our ASP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Aug 2008
Posts: 8
Reputation:
Solved Threads: 0
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.
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.
•
•
Join Date: Jan 2009
Posts: 12
Reputation:
Solved Threads: 1
Here is a thought that is a little dirty but may work for you.
Before reading the text file create a temp text file. when you start reading your file write the line into the temp file then delete it from the original text file. when you are finished reading all of the original text file close the temp file then delete the original, then rename the temp file to that of the original filename.
Before reading the text file create a temp text file. when you start reading your file write the line into the temp file then delete it from the original text file. when you are finished reading all of the original text file close the temp file then delete the original, then rename the temp file to that of the original filename.
![]() |
Similar Threads
- write text file line by line (VB.NET)
- Edit and replace strings in a text file (C++)
- find and replace string in a text file (C)
- Replace element in text file (C++)
- replace data of a text file with user input (C++)
- Storing Words from Text File in Array (C++)
Other Threads in the ASP Forum
- Previous Thread: Record Duplicate ?
- Next Thread: Using Content Linking (NextLink) Component with querystrings
| Thread Tools | Search this Thread |
archive asp asp.net aspandmssqlserver2005 aspandmssqlserver2005connection aspconnection connection database databaseconnection diagnostics dreamweaver excel fso iis microsoft msmsql mssql2005 mssqlserver2005 mssqlserver2005andasp mssqlserverandasp opentextfile record searchbox selectoption server single specfic sqlserver sqlserverconnection toolkit webserver windows7





