473,394 Members | 2,063 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Pattern Search and Extraction of Floating Point number to csv file

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
Jul 19 '05 #1
1 4664
On Thu, 15 Jul 2004, Ram Laxman wrote:
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?


Perhaps one of the regex in:

perldoc -q 'whether a scalar is a number'

Regards,

Brad
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dariusz | last post by:
Despite looking at a number of tutorials in books and online examples on pattern matching - I can't quite get my head around it to work... so need some help. What I have now is a variable that...
5
by: Anton Noll | last post by:
We are using Visual Studio 2003.NET (C++) for the development of our software in the fields digital signal processing and numerical acoustics. One of our programs was working correctly if we are...
5
by: Mantorok Redgormor | last post by:
Would the following determine if the bit pattern for floating point 0.0 and integer 0 are the same? #include <stdio.h> int main(void) <% if(0 == 0.0f) puts("Bit pattern is the same."); ...
15
by: michael.mcgarry | last post by:
Hi, I have a question about floating point precision in C. What is the minimum distinguishable difference between 2 floating point numbers? Does this differ for various computers? Is this...
21
by: Sharon | last post by:
I wish to build a framework for our developers that will include a singleton pattern. But it can not be a base class because it has a private constructor and therefore can be inherit. I thought...
1
by: Eric | last post by:
Hi: I have two files. I search pattern ":" from emails text file and save email contents into a database. Another search pattern " field is blank. Please try again.", vbExclamation + vbOKOnly...
34
by: Steven Nagy | last post by:
So I was needing some extra power from my enums and implemented the typesafe enum pattern. And it got me to thinking... why should I EVER use standard enums? There's now a nice little code...
8
by: googlegroups | last post by:
Hi, I need to parse a binary file produced by an embedded system, whose content consists in a set of events laid-out like this: <event 1<data 1<event 2<data 2... <event n<data n> Every...
3
by: mercuryshipzz | last post by:
#!/usr/bin/perl #use strict; use warnings; sub search_pattern { my $file_name = $_;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.