foreach my $p_num (0..$n_header - 1) {
my $h = $self->_csv->getline($self->_io);
+ my ($code, $string, $position, $record, $field) = $self->_csv->error_diag;
+
$self->_push_error([
$self->_csv->error_input,
- $self->_csv->error_diag,
- 0,
+ $code, $string, $position, $record // 0,
]) unless $h;
if ($self->is_multiplexed) {
}
}
+sub _is_empty_row {
+ return !!all { !$_ } @{$_[0]};
+}
+
sub _parse_data {
my ($self, %params) = @_;
my (@data, @errors);
while (1) {
my $row = $self->_csv->getline($self->_io);
if ($row) {
+ next if _is_empty_row($row);
my $header = $self->_header_by_row($row);
if (!$header) {
push @errors, [
push @data, \%hr;
} else {
last if $self->_csv->eof;
+
# Text::CSV_XS 0.89 added record number to error_diag
- if (qv(Text::CSV_XS->VERSION) >= qv('0.89')) {
- push @errors, [
- $self->_csv->error_input,
- $self->_csv->error_diag,
- ];
- } else {
- push @errors, [
- $self->_csv->error_input,
- $self->_csv->error_diag,
- $self->_io->input_line_number,
- ];
- }
+ my ($code, $string, $position, $record, $field) = $self->_csv->error_diag;
+
+ push @errors, [
+ $self->_csv->error_input,
+ $code, $string, $position,
+ $record // $self->_io->input_line_number,
+ ];
}
last if $self->_csv->eof;
}
=item C<ignore_unknown_columns>
-If set, the import will ignore unkown header columns. Useful for lazy imports,
+If set, the import will ignore unknown header columns. Useful for lazy imports,
but deactivated by default.
=item C<case_insensitive_header>