reduce memory usage importing CSV files

This commit is contained in:
Thomas Bloor 2019-09-10 09:29:17 +01:00
parent 1efabeb45e
commit 9299c46fdf
No known key found for this signature in database
GPG Key ID: 4657C7EBE42CC5CC
2 changed files with 6 additions and 3 deletions

View File

@ -15,9 +15,7 @@ has '+csv_required_columns' => (
sub import_csv {
my ($self) = @_;
my $rows = $self->csv_data;
foreach my $row ( @{$rows} ) {
while ( my $row = $self->get_csv_line ) {
$self->_row_to_result($row);
}
}

View File

@ -67,6 +67,11 @@ has csv_data => (
}
);
sub get_csv_line {
my $self = shift;
return $self->_text_csv->getline_hr( $self->_csv_filehandle );
}
sub check_headers {
my $self = shift;
my $req_headers = $self->csv_required_columns;