• # Perl ?

    Posté par . En réponse au message Programmation sous Scilab. Évalué à 1.

    Si tu as accès à une ligne de commande en dehors de Scilab, tu peux utiliser Perl (ou sed/awk mais je connais moins bien). Le script Perl suivant fonctionne en invoquant "./nomscript.pl fichieratraiter.txt" et il te crée un "fichieratraiter.txt2" contenant le résultat voulu ...

    -----8<-----
    #!/usr/bin/perl -w
    # tmp.pl - parse a file for https://linuxfr.org/forums/31/13748.html
    # usage: ./tmp.pl file.txt

    if($#ARGV != 0)
    {
    die "Please supply names of 1 file (./tmp.pl myfile.txt)\n";
    }

    my($file1) = @ARGV;
    $file2 = $file1 . "2";

    unless(-e $file1 && -f $file1 && -r $file1)
    {
    die "$file1 cannot be accessed\n";
    }

    open FILE1, "$file1"
    or die "Cannot open $file1\n";

    open FILE2, ">$file2"
    or die "Cannot open $file2\n";

    while(!eof(FILE1))
    {
    $line = ;
    if(($line =~ /pignon \(num,円theta,円rayon\)/) || ($line =~ /roue \(num,円theta,円rayon\)/))
    {
    # do nothing in file 2
    }
    else
    {
    $line =~ s/,円/\./g;
    print FILE2 $line;
    }
    }

    close FILE1;
    close FILE2;
    -----8<-----

    Maintenant, tu perds peut-être une info car ton fichier devient :

    1 -0.285599 11.640000 1
    2 -0.281937 11.640000 2
    3 -0.275357 11.642923 2
    4 -0.268777 11.651749 2
    5 -0.262196 11.666651 2
    1 -0.120830 34.200000 5
    2 -0.118433 34.200000 5
    3 -0.116035 34.200000 5
    4 -0.113637 34.200000 5
    5 -0.111239 34.200000 5

    Et tu as perdu l'information séparant pignon de roue