Help parsing large files.
Pat Collins
collins.90 at osu.edu
Mon Dec 6 19:00:52 CST 1999
I'm trying to parse some large files (>75M) to convert the format for
import into a mysql database.
Here is the routine I wrote (I'm still fairly new at perl):
sub convert_to_csv() {
@fcc_files = ('AM.dat','EN.dat','HD.dat','HS.dat');
foreach $fccdata (@fcc_files) {
$newfccfile = "ham_" . lc $fccdata;
open(FCCDAT,"<$fccdata");
open(FCCOUT,">$newfccfile");
while (<FCCDAT>) {
s/\|/","/g; #convert | to ,
s/^/"/; #add initial "
s/.$/"/; #add final "
s/""/\\N/g; #change "" to proper mysql null value \N
#print STDOUT $fccdata;
print FCCOUT $fccdata;
}
close(FCCOUT);
close(FCCDAT);
}
}
This works fine for small files, but fails for large files. Any
thoughts on what might be happening?
Pat
-----------------------------------------------------------------------
To send mail to the Columbus.pm list send email to
columbus-pm-list at happyfunball.pm.org
To unsubscribe send an email to majordomo at hfb.pm.org with
unsubscribe columbus-pm-list youremail at yourdomain.com
-----------------------------------------------------------------------
More information about the Columbus-pm
mailing list