Pattern Search and Extraction of Floating Point number to csv file

From: Ram Laxman (ram_laxman_at_india.com)
Date: 07/15/04


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



Relevant Pages

  • Pattern Search and Extraction of Floating Point number to csv file
    ... Below is the format of text file: ... The statement below extracts the numerical field. ... want to save the same value in my csv file. ... Could anybody help me in this regard? ...
    (comp.lang.perl.modules)
  • Re: Need performance help
    ... Monitor utility output to Comma Separated Value format files. ... At least one CSV file must be specified. ... the matching parameters from all the files are shown on the same chart. ... specify the commands on the command line. ...
    (comp.os.vms)
  • Re: Passing FieldInfo Array from VBS to objExcel.OpenText
    ... The .csv file is comma delimited, text is enclosed in double quotes, dates ... are in format dd-mm-yyyy. ... I am Dutch and Excel on our server is configured to semicolon as field ... xlGeneralFormat), Array(4, xlTextFormat), Array, Array(6, ...
    (microsoft.public.scripting.vbscript)
  • Re: date format changes when I save to CSV via a macro
    ... So it looked like the formatted text was saved in the .CSV file. ... But the problem occurs when I try to bring that data back into excel. ... a date according to my windows short date format. ... When the data is pasted across into the macro workbook, ...
    (microsoft.public.excel.misc)
  • Re: Problem with CSV Date column
    ... to format, so you can specific to include any format you want. ... Dim csvConnection As OdbcConnection ... ' Create connection to folder containing CSV file ... OleDbConnection ...
    (microsoft.public.dotnet.languages.vb)