By looking through the PDL::MISC::IO code I found the syntax:
($val1, $val2, $val3, $name, $val3) = rgrep {sub} *IN,
{TYPES=>[double,double,double,byte,double]}
Note that I have to specify all of the column types or none, empty column masks
do not subsume the default type.
However, it still provides 0's for the string capture from the regexp.
CLIFF SOBCHUK
Core RF Engineering
Phone 613-667-1974 ecn: 8109-71974
mobile 403-819-9233
yahoo: sobchuk
www.ericsson.com<http://www.ericsson.com/>
"The author works for Telefonaktiebolaget L M Ericsson ("Ericsson"), who is
solely responsible for this email and its contents. All inquiries regarding
this email should be addressed to Ericsson. The web site for Ericsson is
www.ericsson.com."
This Communication is Confidential. We only send and receive email on the basis
of the terms set out at
www.ericsson.com/email_disclaimer<http://www.ericsson.com/email_disclaimer>
________________________________
From: Clifford Sobchuk
Sent: May-18-11 10:27 PM
To: Clifford Sobchuk; Craig DeForest
Cc: [email protected]
Subject: RE: [Perldl] Using rgrep multiple times on the same file
What is the correct syntax for rgrep to specify character data in grep? The
following does not seem to work as it returns errors on every line as it
iterates through the file.
($val, $name, $val2) = rgrep {/^\s(\d+)\t(\w+)\t(\d+)$/, TYPES =>
[int,byte,int]} *IN
when I take out the TYPES:
($val, $name, $val2) = rgrep {/^\s(\d+)\t(\w+)\t(\d+)$/} *IN
Then when I query $name it will be a piddle of the correct dimensions of type
double with all values = 0.
Pointers on where I am going wrong? Thanks,
CLIFF SOBCHUK
Core RF Engineering
Phone 613-667-1974 ecn: 8109-71974
mobile 403-819-9233
yahoo: sobchuk
www.ericsson.com<http://www.ericsson.com/>
"The author works for Telefonaktiebolaget L M Ericsson ("Ericsson"), who is
solely responsible for this email and its contents. All inquiries regarding
this email should be addressed to Ericsson. The web site for Ericsson is
www.ericsson.com."
This Communication is Confidential. We only send and receive email on the basis
of the terms set out at
www.ericsson.com/email_disclaimer<http://www.ericsson.com/email_disclaimer>
________________________________
From: Clifford Sobchuk [mailto:[email protected]]
Sent: May-18-11 8:47 PM
To: Craig DeForest
Cc: [email protected]
Subject: Re: [Perldl] Using rgrep multiple times on the same file
Thanks Craig, I just tried using the seek command and it works as well.
Is there a way to specify that one of the columns is a string/character type?
I am parsing data that looks like :
0 0 192 alpha 0 locked -------- 485 -38.75 34 205 0x00000fe5
Using rgrep to capture the first 4 fields and the 9th field. The data is
intermixed with other data in the file so I can't use rcols.
($a, $b, $c, $d, $e) = rgrep
{/^\s+(\d)\t(\d)\t(\d+)\t(\w+)\t\d\t\w+\s+w+\s+\d+\t(\-\d+\.\d+)\s+\d+\t\d+.*/}
*IN;
$d is a string and when I print the number of elements it is the same as the
other columns, however, I can't print any of the individual values, nor find
the uniq values.
The datatypes available doesn't have a character or string type, so I am not
sure how to change it so that I can read it.
CLIFF SOBCHUK
Core RF Engineering
Phone 613-667-1974 ecn: 8109-71974
mobile 403-819-9233
yahoo: sobchuk
www.ericsson.com<http://www.ericsson.com/>
"The author works for Telefonaktiebolaget L M Ericsson ("Ericsson"), who is
solely responsible for this email and its contents. All inquiries regarding
this email should be addressed to Ericsson. The web site for Ericsson is
www.ericsson.com."
This Communication is Confidential. We only send and receive email on the basis
of the terms set out at
www.ericsson.com/email_disclaimer<http://www.ericsson.com/email_disclaimer>
________________________________
From: Craig DeForest [mailto:[email protected]]
Sent: May-18-11 8:18 PM
To: Clifford Sobchuk
Cc: [email protected]
Subject: Re: [Perldl] Using rgrep multiple times on the same file
I think you need to reopen the file.
(Mobile)
On May 18, 2011, at 8:00 PM, Clifford Sobchuk
<[email protected]<mailto:[email protected]>> wrote:
Hi Folks, I am trying to use rgrep to pull out data from the same file that
occur in different areas of the file using rgrep. My first use of rgrep works
as expected, it is upon subsequent calls that I get nothing returned.
================================================================
Ex:
pdl> open IN, "< LAV800_BTS232_APR08_BETA-LAUBSC-20110428134127.txt"
pdl> ($rx0,$rx1) = rgrep {/^\t(\d+)\t(\d+)$/} *IN
pdl> p nelem $rx0
7760
pdl> p nelem $rx1
7760
pdl> $rx0=()
pdl> p nelem $rx0
1
pdl> p nelem $rx1
7760
pdl> ($rx0,$rx1) = rgrep {/^\t(\d+)\t(\d+)$/} *IN
pdl> p nelem $rx0
1
pdl> p nelem $rx1
1
================================================================
I am actually grepping different regexp but doing the same one seemed like the
most obvious way to show that it isn't working the second time it is called.
Any ideas? Thanks,
CLIFF SOBCHUK
Ericsson
Core RF Engineering
Calgary, AB, Canada
Phone 613-667-1974 ECN 8109 x71974
Mobile 403-819-9233
[email protected]<mailto:[email protected]>
yahoo: sobchuk
http://www.ericsson.com/
"The author works for Telefonaktiebolaget L M Ericsson ("Ericsson"), who is
solely responsible for this email and its contents. All inquiries regarding
this email should be addressed to Ericsson. The web site for Ericsson is
www.ericsson.com."
This Communication is Confidential. We only send and receive email on the basis
of the terms set out at
www.ericsson.com/email_disclaimer<http://www.ericsson.com/email_disclaimer>
_______________________________________________
Perldl mailing list
[email protected]<mailto:[email protected]>
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl