Pattern Search and Extraction of Floating Point number to csv file
From: Ram Laxman (ram_laxman_at_india.com)
Date: 07/15/04
- Next message: vertigo: "Re: return hash"
- Previous message: Jürgen Exner: "Re: return hash"
- Next in thread: Brad Baxter: "Re: Pattern Search and Extraction of Floating Point number to csv file"
- Reply: Brad Baxter: "Re: Pattern Search and Extraction of Floating Point number to csv file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 15 Jul 2004 08:22:52 -0700
Hi all,
Iam new to perl programming. I have written a program which
read a text file and import some values to the csv file searching some
tags(keyword) in the text file.
Below is the format of text file:
No of transactions = 10
Data exchanged with device = 0.5 bytes
Data sent to device = 0.04 KBytes
while( $key = <TEXTFILE> ) {
# check if it matches the tag
if ( $key =~ /$tag/i ) {
@arr_field = split( /$tag/i, $key );
foreach $afield( @arr_field ) {
if( $afield =~ /(\d+)/ ) {
$field = $1; # extract the numerical field
}
}
print CSV "$field\,"; # writes the numerical field to the
result file
last;
The statement below extracts the numerical field.
if( $afield =~ /(\d+)/
I don't know how to extract the floating point numbers.(For example
Data exchanged with device = 0.5 bytes) without truncation and
want to save the same value in my csv file.
Could anybody help me in this regard?
Regards
Ram Laxman
- Next message: vertigo: "Re: return hash"
- Previous message: Jürgen Exner: "Re: return hash"
- Next in thread: Brad Baxter: "Re: Pattern Search and Extraction of Floating Point number to csv file"
- Reply: Brad Baxter: "Re: Pattern Search and Extraction of Floating Point number to csv file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|