Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: formatting help

by Buckaroo Buddha (Scribe)
on Jun 30, 2000 at 19:58 UTC ( [id://20614]=note: print w/replies, xml ) Need Help??


in reply to formatting help

finally, a node that i can help with *grin*
i'm assuming that there is no header row
in your text files
we will also assume you want to return columns
6, 12, and 18
while(<>){ # read through each file specified on the command line one + line at a time my @temp = split(',',$_); # take that one line and split it into a +n array determined by the commas my ($section,$value1,$value2) = ($temp[6],$temp[12],$temp[18]); # +set names to specific spots for readability $section =~ s/\"//g; # remove the ", you may have to remove 'g' to + make this work $value1 =~ s/\"//g; # it's off the top of my head ;) $value2 =~ s/\"//g; $ALLDATA{$section} = push [($value1,$value2)]; #put an array of tw +o numbers into an array those } # end while<> foreach my $key (sort keys %ALLDATA) { # go through each section (in o +rder) print "$key\n"; foreach my $array (@{$ALLDATA{$key}}) { print "\t"; foreach my $value (@{$ALLDATA{$key}[$array]} { print "$value,"; } print "\n"; } print "END_SECTION\n"; }
save the above line of code to a file
execute the command line
 perl progname.pl < datafilename >
  email me if it dosen't work achesser@nortelnetworks.com
i wrote that off the top of my head

Log In?
Username:
Password:

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

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

    No recent polls found