PDA

View Full Version : create multiple files from a single file


GurusGuru
09-03-2002, 07:58 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.

This can be achieved with a javascript. Can anyone help me out in creating this script.

mordred
09-03-2002, 09:04 PM
Unfortunetely client-side javascript is incapable of creating files (except for cookies). Though it's unclear where you actually want your process to happen, I can only assume that you originally thought of the server's side. If I'm correct on this, this thread should be better moved to a forum of the server-side language of your choice.

GurusGuru
09-03-2002, 10:40 PM
The data is on my PC. I need to convert the data into files and then upload them on the server.

mordred
09-04-2002, 02:04 AM
You also need a server-side script to handle the file upload, or do you intend to do that with FTP manually?

joh6nn
09-04-2002, 02:56 AM
i think he means he wants to write something like a shell script in unix, or a batch file in dos, to handle the data separation for him. you could do it with microsoft's WSH, but there's not much point in doing it that way.

here's a batch mode text editor that might help you out:
http://www.silveragesoftware.com/hffr.html

GurusGuru
09-04-2002, 07:51 AM
I would like to upload the files manually. Say the contents of the file xyz.txt are

abc|123|a@b.com|blue|www.gif
bcd|245|d@d.com||qqq.gif
efg|145|as@sd.com|green|eee.gif

etc. etc
The file contains each record in a single line and the fields are delimited by |.

What I need is a script that runs on my pc and converts xyz.txt to abc.dat, bcd.dat, efg.dat etc. etc.

The contents of file abc.dat will be formatted in a single line:

123
a@b.com
blue
www.gif

File bcd.dat will look like
245
d@d.com

qqq.gif

joh6nn
09-04-2002, 11:47 PM
you can't do this with javascript. javascript can't read or write to files.

you need something like a batch file, or the program that i linked you too, or something along those lines. javascript can't do this.