Gangabass has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
I have an error "Out of memory" while parsing large (100 Mb) XML file
use strict; use warnings; use XML::Twig; my $twig=XML::Twig->new(); my $data = XML::Twig->new->parsefile("divisionhouserooms-v3.xml")->sim +plify( keyattr => []); my @good_division_numbers = qw( 30 31 32 35 38 ); foreach my $property ( @{ $data->{DivisionHouseRoom}}) { my $house_code = $property->{HouseCode}; print $house_code, "\n"; my $amount_of_bedrooms = 0; foreach my $division ( @{ $property->{Divisions}->{Division} } ) { next unless grep { $_ eq $division->{DivisionNumber} } @good_d +ivision_numbers; $amount_of_bedrooms += $division->{DivisionQuantity}; } open my $fh, ">>", "Result.csv" or die $!; print $fh join("\t", $house_code, $amount_of_bedrooms), "\n"; close $fh; }
What i can do to fix this error issue?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Parsing huge XML file
by zentara (Archbishop) on Sep 03, 2011 at 15:53 UTC | |
by Gangabass (Vicar) on Sep 04, 2011 at 00:40 UTC | |
Re: Parsing huge XML file
by Anonymous Monk on Sep 03, 2011 at 14:43 UTC | |
Re: Parsing huge XML file
by Jenda (Abbot) on Sep 08, 2011 at 09:44 UTC | |
Re: Parsing huge XML file
by afoken (Chancellor) on Sep 05, 2011 at 07:02 UTC |
Back to
Seekers of Perl Wisdom