Thread Suche in txt (6 answers)
Opened by Gast at 2004-08-25 11:50

Rippchen
 2004-08-25 12:55
#49625 #49625
User since
2004-08-25
12 Artikel
BenutzerIn
[default_avatar]
Das haut noch nicht so ganz hin am besten ich poste mal den gesammten Quellcode. Der ist baer noch ein bissel unübersichtlich.
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/perl
#require 'ctime.pl';
use POSIX qw(strftime);

$in = $ARGV[0];


open ( IN, "<$in") || die "ERROR, can't open $in";

sub getcfg()
{
 while ( <IN> ){
   if ( $_ =~ /\[adudata.*\]/){
     return 0;
   }
   if ( $_ =~ /starttime=.*/){
     @starttime= split ("=",$_);
   }
   if ( $_ =~ /iSampleRate=.*/){
     @iSampleRate= split ("=", $_);
   }
   if ( $_ =~ /szLabel=.*/){
     @szLabel= split ("=", $_);
   }
   if ( $_ =~ /SensUnit=.*|MeasUnit=.*/){
     @SensUnit= split ("=", $_);
   }
   if ( $_ =~ /startPtime=.*/){
     @startPtime= split ("=", $_);
   }
   if ( $_ =~ /iSampleRate=.*/){
     @iSampleRate=split ("=", $_);
   }
   if ( $_ =~ /iChGroup=.*/){
     @iChGroup=split ("=", $_);
   }
   if ( $_ =~ /iRPMChannel=.*/){
     @iRPMChannel=split ("=", $_);
   }
 }
};

sub printdata()
{
 while ( <IN> )
 {
   #test auf zahl
   if ($_ =~ /^([+-]?\d+(\.\d+)?([Ee][+-]?\d+)?)/ ){
     print OUT "$_";
   }
   else{
     return 0;
   }
 }
};


sub printheader()    #An dieser Stelle soll abgefragt
        #werden wieviele channels es gibt.
{            
 printf (OUT "ch $ch[1]"."\n");
 while ( <IN> )
 {
   $anz = `grep -c "^aduchannel" $_`;
   chomp $anz;
   printf (OUT "number of channels $anz"."\n")
 }
 printf (OUT "Samplerate $iSampleRate[1]");
 printf (OUT "divided by Gain 1  "."\n");
};


while ( <IN> )
{


    if ( $_ =~ /\[aduchannel.*\]/ ){
        chop;chop;
        @ch= split ("aduchannel",$_);
        $zeile= $ARGV[0];
        @name= split ('-',$zeile);
        $out = sprintf ("%s_ch%d.txt", $name[0] , $ch[1] , $szLabel[1] );
        &getcfg();
        $timestr=strftime("%Y%m%d-%H.%M",localtime($starttime[1]));
        $out = $name[0]."_".$timestr."_ch".$ch[1]."_".$szLabel[1].".txt";
        open ( OUT, ">$out" ) || die "ERROR, can't open $out";
        }



    if ( $_ =~ /\[adudata$ch[1]\]/ ){
        &printheader();
        &printdata();
    }


}


close IN;
close OUT;


edit renee: [code]-Tags spendiert\n\n

<!--EDIT|renee|1093424653-->
Die letzte Stimme, die man hört, bevor die Welt explodiert, wird die Stimme eines Experten sein, der sagt: Das ist ... unmöglich!

View full thread Suche in txt