Hi Erasmo Perez

I think What u asking can be done in this way( There might be some more
other optimized way)

The code is as follows


use strict;
use warnings;
open(FH,"your_source_csv_filename");
my @arr = <FH>;
close(FH);
open(LS,">>your_modified_csv_filename");
foreach my $el(@arr)
 {
   print LS ((split/,/,$el)[1]).",".((split/,/,$el)[2])."\n";
 }
close(LS);

Thanks & Regards
Anirban Adhikary.

On Sat, Jul 12, 2008 at 10:54 AM, Erasmo Perez <[EMAIL PROTECTED]>
wrote:

> Hi dear Perl list:
>
> I would like to thank you for all the support I have received from you
> in my last couple of questions.
>
> But here is another question:
>
> I would like to know how could I transform the following CSV file:
>
> 1,2,3,4,5,6
> 2,3,4,6,7,8,9
> 3,876,986,876,765
> ...
> 987,983,654,990,654
> 989,876,234,56,67
>
> into the following CSV file:
>
> 1,2
> 1,3
> 1,4
> 1,5
> 1,6
> 2,3
> 2,4
> 2,6
> 2,7
> 2,8
> 2,9
> 3,876
> 3,986
> 3,876
> 3,765
> ...
> 987,983
> 987,654
> 987,990
> 987,654
> 989,876
> 989,234
> 989,56
> 989,67
>
> I mean: the new CSV file must be composed of merely two columns, the
> first column needs to be the first value in the row of the input CSV.
> The second column must be the following numbers that follow the first
> number in the row, up to the end of the line
>
> at the next line of the input CSV, again, the first number of the row
> must be attached to the remaning numbers in its row, a la
>
> a,b,c,d
> f,g,h,i,j
>
> to be converted in
>
> a,b
> a,c
> a,d
> f,g
> f,h
> f,i
> f,j
>
> How could I accomplish this using Perl ?
>
> Thank you very much for any reply.
>
> Kind regards
>
> Erasmo
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>

Reply via email to