Hi Monks, I have a script that converts an xlsx spreadsheet into a comma seperated csv format and pushes to an array. The next step deletes any dupliacte lines.
If i print to screen it looks fine and has done what i expect. But when i use print to show me where the newlines are it shows as one line.
How do i get a newline at the end of each row ie the Pass column.# test.pl #!/usr/bin/perl use strict; use warnings; use Spreadsheet::BasicRead; open( STDERR, ">&STDOUT" ); my $xlsx_INFILE =("C:\\Temp\\Test.xlsx"),, 1; #Set-up Files my @csvtemp; my $ss = new Spreadsheet::BasicRead($xlsx_INFILE) or die " oops \n" +; # convert $INFILE to a csv file my $name = ''; my $row = 0; while ( my $data = $ss->getNextRow() ) { $row++; $name = join( ',', @$data ); push @csvtemp, $name . "\n" if ( $name ne "" ); } my @csvsort; my %seen; # remove any duplicates lines foreach (@csvtemp){ push @csvsort, $_ if !$seen{$_}++ ; } print("'@csvtemp'");
expected data__DATA__ Name job gender Data of Sick Reg Pass marshall plumber Male ten Jones baker Male none Smith cleaner Male none 387622 Tucker cleaner Female none 387628 Butcher blacksmith Male none 386626 Patel Builder Male none Black plumber Male Two Cooper baker Female none Jess cleaner Male none Booker cleaner Male Six 387626 Patel Builder Male none Black plumber Male Two Cooper baker Female none Jess cleaner Male none Booker cleaner Male Six 387626
'Name,job,gender,Data of Sick,Reg,Pass' 'marshall,plumber,Male,ten,,' 'Jones,baker,Male,none,,' 'Smith,cleaner,Male,none,387622,' 'Tucker,cleaner,Female,none,387628,' 'Butcher,blacksmith,Male,none,386626,' 'Patel,Builder,Male,none,,' 'Black,plumber,Male,Two,,' 'Cooper,baker,Female,none,,' 'Jess,cleaner,Male,none,,' 'Booker,cleaner,Male,Six,387626,'
In reply to Perl to Add newline at the end of each row of comma seperated strings in an array ? by john.tm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |