...

View Full Version : Mutiple files from a single file



GurusGuru
09-08-2002, 09:22 PM
I have a large file containing an Alumni database. Each line has a separate record and the fields in the records are delimited by pipes (|). say the fields are username, FName, LName, Address, City, State, Country ..........about 24 fields.

Now I wish to convert this single file to mutiple files - one file of each record (each user). The username becomes the file name (username.dat) and all the other fields for the user is stored in one file one below the other.
FName
LName
Address,
City
..
..
etc.

Is it possible for a perl/cgi script to perform the above function.

chrisvmarle
09-08-2002, 10:17 PM
working on it :)

chrisvmarle
09-08-2002, 10:43 PM
It took a while, but here it is.
And I love it, though I say it myself.

On *nix you should use it like this:
convert.cgi database filename
or, if you want old userfiles overwritten
convert.cgi database filename overwrite
(you could also use "yes" or "1" in stead of "overwrite")
Example: convert.cgi database.db
Example 2: convert.cgi database.db yes

On Win32 like this:
perl convert.cgi database filename
or, if you want old userfiles overwritten
perl convert.cgi database filename overwrite
(you could also use "yes" or "1" in stead of "overwrite")
Example: perl convert.cgi database.db
Example 2: perl convert.cgi database.db yes

Mzzl, Chris

P.S. The file's attached

GurusGuru
09-08-2002, 11:34 PM
I tried running it but I don't know where it saved the files.

Opening database file: database.db Reading data Creating files: Working on filename Opening filename.dat Saving data Data

I am unable to run this script on the PC. I am, however, able to run other cgi scripts on my PC. I have Perl and apache installed on my PC

chrisvmarle
09-08-2002, 11:40 PM
It saves the files in the dir where you run convert.cgi

Mzzl, Chris

GurusGuru
09-08-2002, 11:59 PM
Thanks the script is just too good. I was able to run it on my PC and convert the files. On the server I couldn't find the converted files.

2nd Request.
Can we reverse the script. Where it reads the multiple files and converts into a single file.

GurusGuru
09-09-2002, 12:01 AM
The files are there on the server also. Once again thanks a lot.

chrisvmarle
09-09-2002, 06:11 AM
Originally posted by GurusGuru
2nd Request.
Can we reverse the script. Where it reads the multiple files and converts into a single file.

I'll have a look at that today, but first I have to go to school :(
I'll be back around 4:00 PM (GMT+1)

Mzzl, Chris

chrisvmarle
09-09-2002, 03:01 PM
Here is the new file, it contains 4 files; two docs and two programs.

I did a little update to convert.cgi too.

Mzzl, Chris

P.S. tell me what you think

GurusGuru
09-10-2002, 08:34 AM
Genius.... Both the scripts are fantastic and they work beautifully.

Thanks again.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum