Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: XML::CSV out of memory

by slugger415 (Monk)
on Mar 26, 2015 at 16:58 UTC ( [id://1121422]=note: print w/replies, xml ) Need Help??


in reply to Re: XML::CSV out of memory
in thread XML::CSV out of memory

Thanks for the replies and suggestions. Yes it is strange, the system now has 12 gigs of memory. My own workstation has 16 gigs and I'm not getting the out of memory error running the same script. Anyway.

So it's probably a dumb question, but do I even need Text::CSV for your suggestion? Couldn't the script just put $n lines of text into an array and feed those to @arr_of_data? And how would I do $csv_obj->print_xml("out.xml") at each iteration without clobbering the previous iteration? (ok, you can tell I'm still learning here - begging patience...)

Thanks.

Replies are listed 'Best First'.
Re^3: XML::CSV out of memory
by RonW (Parson) on Mar 26, 2015 at 17:31 UTC
    do I even need Text::CSV for your suggestion? Couldn't the script just put $n lines of text into an array and feed those to @arr_of_data?

    Text::CSV will insure you are reading complete records. If you can be sure that your input files have no embedded "new lines" in the CSV records, then you could skip Text::CSV.

    And how would I do $csv_obj->print_xml("out.xml") at each iteration without clobbering the previous iteration?

    Try (untested):

    open(my $outFH, '>', "out.xml"); while (<>) { ...; $csv_obj->print_xml($outFH); }
Re^3: XML::CSV out of memory
by stonecolddevin (Parson) on Mar 26, 2015 at 18:57 UTC

    The example seems to call for Text::CSV_XS in this instance:

    $default_obj_xs = Text::CSV_XS->new({quote_char => '"'}); $csv_obj = XML::CSV->new({csv_xs => $default_obj_xs});

    It's really not hurting you to use it, so you might as well honestly.

    Three thousand years of beautiful tradition, from Moses to Sandy Koufax, you're god damn right I'm living in the fucking past

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1121422]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-03-29 06:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found