It's definitely possible. The first thing to do is define your problem
a little better. Do you want four items per row, or do you want to
slurp the entire file and make one long comma-separated list?
This is a good starting project because it makes you learn how to open,
read, and write to files.
Here's a little snippet to get you started:
###############################
use strict;
use warnings;
open(INFILE,"<xy.txt") or die("Couldn't open 'xy.txt' for reading!\n");
open(OUTFILE,">xy.csv") or die("Couldn't open 'xy.csv' for writing!\n");
#reading and writing
while($_ = <INFILE>){
chomp $_;
#do something with $_...
print OUTFILE "This will be written to 'xy.csv'.\n";
}
###############################
Also check out:
perldoc -f open
perldoc -f print
You should be able to figure out how to rearrange it into the
appropriate format. If you have any trouble, post your code here and we
can help you.
-----Original Message-----
From: Andrej Kastrin [mailto:[EMAIL PROTECTED]
Sent: Monday, November 28, 2005 11:45 AM
To: [email protected]
Subject: From column to row?
Hi, I am totally NOOB in Perl and here is my first problem, which I
couldn't solve...
I have column data in file xy.txt, which looks like:
AAAAA
BBBBB
CCCCC
ABCDD
..
.
Now I have to transform this to row data file in the following way:
"AAAAA","BBBBB","CCCCC","ABCDD"
Is that possible?
Thanks in advance, Andrej
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>