Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; use Spreadsheet::ParseExcel; use DateTime::Format::Excel; use Data::Dumper; ... foreach my $worksheet (@{$excel_sheet -> {Worksheet}}) { $worksheet -> {MaxRow} ||= $worksheet -> {MinRow}; # Skip worksheet if it doesn't contain data. next if $worksheet -> {MinRow} > $worksheet -> {MaxRow}; foreach my $row ($worksheet->{MinRow} .. $worksheet->{MaxRow}) { # Correct values or skip them: next unless defined $worksheet->{Cells}[$row][0]->{Val}; warn Dumper $worksheet->{Cells}[$row][0]->{Val}; if ( $worksheet->{Cells}[$row][0]->{Val} =~ /^\d{5}/ ) { my $xlsx_rows = $worksheet->{Cells}[$row]; # Send data send_data( zipcode => $xlsx_rows->[0]->{Val} || '', firstname => $xlsx_rows->[1]->{Val} || '', lastname => $xlsx_rows->[2]->{Val} || '', ); }else{ # Send flag as DONE once it reach the end of file or if there +is no data send_data( zipcode => 'DONE', # Flag ); } } } ...
DONE 01111 02334 09999
01111 02334 09999 DONE
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reading a spreadsheet
by Athanasius (Archbishop) on Feb 18, 2015 at 16:24 UTC | |
by Anonymous Monk on Feb 18, 2015 at 16:37 UTC | |
by Athanasius (Archbishop) on Feb 18, 2015 at 16:50 UTC | |
by Anonymous Monk on Feb 18, 2015 at 18:05 UTC | |
by Athanasius (Archbishop) on Feb 19, 2015 at 01:57 UTC | |
|
Re: Reading a spreadsheet
by runrig (Abbot) on Feb 18, 2015 at 16:23 UTC | |
by ww (Archbishop) on Feb 18, 2015 at 16:38 UTC |