Gossamer Forum
Home : Products : DBMan : Customization :

reverse External Text File Mod

Quote Reply
reverse External Text File Mod
Hi,

Two years ago I got the included code to implement the External File mod made by the famous JPDENI.
Purpose : to split existing text fields records from the flat text db file into separate .txt files.

Now I want to do the reverse.

Anyone got any idea how to rewrite this code so the tekst in the sepreate .txt files will be placed in the db file again?Unsure

=code=====================================

my ($line, @data, $field);
$db_file_name = "c:/cgi-bin/dbman/default.db";
$outdir = "c:/cgi-bin/dbman/auth/";
open (DB, $db_file_name);
LINE: while (<DB>) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
$line = $_; chomp ($line);
@data = &split_decode($line);
# Assuming you want call your files as ID.txt where ID is in field 0
$outfile = @data[0].".txt";
open (OUT, ">$outdir/$outfile");
# Assuming data you want to export are in field 3
print OUT @data[6];
close OUT;
}
close DB;
exit;


sub split_decode
{
my ($input) = shift;
$input =~ s/\Q|\E$/| /o;
my (@array) = split (/\Q|\E/o, $input);
for ($i = 0; $i <= $#array; $i++)
{
$array[$i] =~ s/~~/|/og;
$array[$i] =~ s/``/\n/g;
}
return @array;
}

=eof============================
Close Watch
LyricZ http://www.e-lyricz.com
NL

Last edited by:

close_watch: Oct 16, 2002, 11:25 AM
Quote Reply
Re: [close_watch] reverse External Text File Mod In reply to
Are you using codes earlier than the official external test file mod? http://www.jpdeni.com/...Mods/externaltxt.txt

It would seem easy to stop having them save in an external file by removing the codes which make this happen. But are you wanting the script itself to take the external txt files and place that information back into the datbase?

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] reverse External Text File Mod In reply to
In Reply To:
Are you using codes earlier than the official external test file mod? http://www.jpdeni.com/...Mods/externaltxt.txt
=(http://www.gossamer-threads.com/...g=close_watch;#94087) one-time-run script outside the mod (after mod was released)
In Reply To:
It would seem easy to stop having them save in an external file by removing the codes which make this happen. But are you wanting the script itself to take the external txt files and place that information back into the datbase?

=Yes I need to do the reverse (placing it back into the database) by a rewritten external script (like the code I mentioned in my first post)
Close Watch
LyricZ http://www.e-lyricz.com
NL

Last edited by:

close_watch: Oct 17, 2002, 1:02 AM