Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: I would like to find a good logic to parse the data

by greatshots (Pilgrim)
on May 25, 2007 at 03:02 UTC ( #617388=note: print w/ replies, xml ) Need Help??


in reply to I would like to find a good logic to parse the data

ooops, In our production server I am not allowed to load any modules. I need to use this parsing scripts, in our production server. thanks for the Idea. I will look into Text::CSV_XS module, and try my best.


Comment on Re: I would like to find a good logic to parse the data
Re^2: I would like to find a good logic to parse the data
by GrandFather (Sage) on May 25, 2007 at 03:14 UTC

    You may be able to get around the letter of the law by copying the important parts of Text::CSV into your code rather than installing the whole thing.


    DWIM is Perl's answer to Gödel
Re^2: I would like to find a good logic to parse the data
by varian (Chaplain) on May 25, 2007 at 08:38 UTC
    I am not allowed to load any modules
    Core modules do not have to be installed so you may benefit from Text::Balanced.
    Below code is not bullit proof but should be sufficient to process your data:
    #!/usr/bin/perl use strict; use warnings; use Text::Balanced qw(extract_quotelike); sub getfields { my ($str) = @_; my @fields; my $field = ''; while ($str) { $field .= $str =~ s/^(\s*)// ? $1 :''; my $extracted; if ($str=~/^["']/) { ($extracted,$str) = extract_quotelike($str); $field.=$extracted; } else { ($extracted,$str) = split(',',$str,2); push @fields,$field.$extracted; $field=''; } } return @fields; } while (my $line = <DATA>) { chomp($line); print "$_\t" foreach ( getfields($line) ); print "\n"; } __DATA__ Submitted,"696,028","50,946","15,127,534","14,458,899" Expired,245,275,273,248 Less in,90.12%,90.49%,90.04%,89.55%
    Output is:
    Submitted "696,028" "50,946" "15,127,534" Expired 245 275 273 248 Less in 90.12% 90.49% 90.04% 89.55%
Re^2: I would like to find a good logic to parse the data
by Tux (Monsignor) on Jun 01, 2007 at 09:44 UTC

    You don't need to have write-access to the main perl installation tree at all:

    # perl Makefile.PL PREFIX=/home/greatshots/perl5 # make test # make install UNINST=1

    Do so with all modules you need, and add the PATH's to your env $PERL5LIB


    Enjoy, Have FUN! H.Merijn

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2015-07-04 21:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls