Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to split a text file 3

Status
Not open for further replies.

Mike Gagnon

Programmer
Apr 6, 2002
8,067
CA
I need to split a text file in 2.
The text file contains about 110,000 lines and I need to split it in about half.
I looked at MEMLINES, ALINES, FILETOSTR. I'm out of ideas.
Any one have a quick and dirty way to do this?


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Hi dbMark

Good point.

if there is no line found, but the file has one line without line feed the program wouldn't write that to a split file. But that's a case were you won't need any split anyhow...

My code would output the whole file as part1.dat then.

The limits of FILETOSTR and varible memory usage of a var are higher than most people think:

Code:
* WARNING: This will lock up the system before an error occurs!
local lcTest, llNOError
lcTest = ""
llNOError = .T.
On Error llNoError = .F.
do while llNoError
   lcTest = lcTest + SPACE(16777184)
   ? len(lcTest)
enddo
WARNING: This will lock up the system!

The limit of FILETOSTR() should be about this...
Of course the FAQ on file handling of >2GB is nice anyhow, as Reading a large file in fully get's slower, if the file is larger than 64MB anyway. About 100000 lines each about 100-200 chars is in a range of 10-20 MB.

Bye, Olaf.
 
The limit of FILETOSTR() should be about this...
Of course the FAQ on file handling of >2GB is nice anyhow, as Reading a large file in fully get's slower, if the file is larger than 64MB anyway. About 100000 lines each about 100-200 chars is in a range of 10-20 MB.

The average file size I'm dealing with is between 15mb to 33mb (so far). I still have room to grow.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top