Revision 61a56da0
Von Sven Schöling vor mehr als 13 Jahren hinzugefügt
SL/Helper/Csv.pm | ||
---|---|---|
120 | 120 |
|
121 | 121 |
while (1) { |
122 | 122 |
my $row = $self->_csv->getline($self->_io); |
123 |
last if $self->_csv->eof; |
|
124 | 123 |
if ($row) { |
125 | 124 |
my %hr; |
126 | 125 |
@hr{@{ $self->header }} = @$row; |
127 | 126 |
push @data, \%hr; |
128 | 127 |
} else { |
128 |
last if $self->_csv->eof; |
|
129 | 129 |
push @errors, [ |
130 | 130 |
$self->_csv->error_input, |
131 | 131 |
$self->_csv->error_diag, |
132 | 132 |
$self->_io->input_line_number, |
133 | 133 |
]; |
134 | 134 |
} |
135 |
last if $self->_csv->eof; |
|
135 | 136 |
} |
136 | 137 |
|
137 | 138 |
$self->_data(\@data); |
t/helper/csv.t | ||
---|---|---|
1 |
use Test::More tests => 36;
|
|
1 |
use Test::More tests => 37;
|
|
2 | 2 |
use SL::Dispatcher; |
3 | 3 |
use Data::Dumper; |
4 | 4 |
use utf8; |
... | ... | |
264 | 264 |
|
265 | 265 |
is_deeply( ($csv->errors)[0], [ 'description', undef, 'header field \'description\' is not recognized', undef, 0 ], 'strict_profile without ignore_columns throws error'); |
266 | 266 |
|
267 |
##### |
|
268 |
|
|
269 |
$csv = SL::Helper::Csv->new( |
|
270 |
file => \"Kaffee", |
|
271 |
header => [ 'description' ], |
|
272 |
class => 'SL::DB::Part', |
|
273 |
); |
|
274 |
$csv->parse; |
|
275 |
is_deeply $csv->get_data, [ { description => 'Kaffee' } ], 'eol bug at the end of files'; |
|
267 | 276 |
|
268 | 277 |
# vim: ft=perl |
Auch abrufbar als: Unified diff
Bugfix: Kein newline am Ende der Datei verschluckte die letzte Zeile.