Thread Bestimmte Zeilen und Spalten aus txt. Datei in eine andere txt.-Datei schreiben (14 answers)
Opened by MrDizzle at 2009-02-25 16:35

hlubenow
 2009-02-25 20:01
#119151 #119151
User since
2009-02-22
875 Artikel
BenutzerIn
[default_avatar]
Hi,

meinst Du das so (?):
Code (perl): (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
#!/usr/bin/perl

use warnings;
use strict;

my $infile = "VelocityPlot.dem";
my $outfile = "test.inp";

open(FH, "<$infile");
my @a = <FH>;
close(FH);

my $alen = @a;
my $i;
my @b;

open(FH, ">$outfile");

for($i = $alen - 101; $i < $alen; $i++)
{
    @b = split("\t", $a[$i]);
    my $d = "";
    for(my $u = 3; $u <= 6; $u++)
    {
        $d = $d . $b[$u - 1];
        if($u < 6)
        {
            $d = $d . ",";
        }
    }
    print(FH "$d\n");
}

close(FH);

Gruß

View full thread Bestimmte Zeilen und Spalten aus txt. Datei in eine andere txt.-Datei schreiben