reduce memory usage importing CSV files
This commit is contained in:
parent
19b4530810
commit
b3139c3bf0
2 changed files with 6 additions and 3 deletions
|
@ -15,9 +15,7 @@ has '+csv_required_columns' => (
|
||||||
sub import_csv {
|
sub import_csv {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
my $rows = $self->csv_data;
|
while ( my $row = $self->get_csv_line ) {
|
||||||
|
|
||||||
foreach my $row ( @{$rows} ) {
|
|
||||||
$self->_row_to_result($row);
|
$self->_row_to_result($row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
sub check_headers {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $req_headers = $self->csv_required_columns;
|
my $req_headers = $self->csv_required_columns;
|
||||||
|
|
Reference in a new issue