HELP: Joining 5 large text files

S

Stuart

Hi,

Please can anyone help me join 5 large (1.8gb) text files togeather
to create 1 very large file.

I have some code in PHP but it bombs out at 2gb (seems there is a limit
and php needs re compiling, something thats not an option for me)

I don't want to take up all the servers resources so something that uses
little memory would be very good indeed!

here's the php code if it help...

<?php
set_time_limit(14400000);

$file[0] = "file1.txt";
$file[1] = "file2.txt";
$file[2] = "file3.txt";
$file[3] = "file4.txt";
$file[4] = "file5.txt";

$target = "output.txt";
$handle = fopen($target, 'a');

foreach ($file as $var) {
$c_handle = fopen($var, 'r');
do {
$content = fread($c_handle,1000000);
fwrite($handle, $content);
} while (!empty($content));
fclose($c_handle);
}
?>


all the best

Stu
 
B

bmay2068

I have some code in PHP but it bombs out at 2gb (seems there is a limit
and php needs re compiling, something thats not an option for me)

2gigs is a magic number for the maximum file size on some OSes; 2^31.
(You loose a bit due to signed variable usage on some file systems.)

What OS, Architecture are you using? What type of file system i.e.
XFS, EXT2, WINDoze

Cheers!
 
J

Joe Smith

Stuart said:
create 1 very large file.

I have some code in PHP but it bombs out at 2gb (seems there is a limit
and php needs re compiling, something thats not an option for me)

You're screwed. Unless PHP is recompiled with LARGE_FILE is enabled,
you will *not* be able to write anything past byte number 2147483647.
-Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top