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
#usr\bin\perl -w my $file="Test.txt"; my @a; my @neu; my @idx; my @gene; my @transcript; my @name; my @location; my @position; my @type; my @nuc; my @cov; my @aa; my @cond; my @hint; my @web; my @hgvs; open (IN,$file) or die "Datei $file konnte nicht gefunden werden\n"; while (<IN>){ chomp ($_); @a=split(/\t/, $_ ); # push (@idx, $a[0]); push (@gene, $a[1]); push (@transcript, $a[2]); push (@name, $a[3]); push (@location, $a[4]); push (@position, $a[5]); push (@type, $a[6]); push (@nuc, $a[7]); push (@cov, $a[8]); push (@aa, $a[9]); push (@cond, $a[10]); push (@hint, $a[11]); push (@web, $a[12]); push (@hgvs, $a[13]); } close IN; foreach (1..$#a){ @neu=($a[1],"\t", $a[13],"\n"); } open (DATEI, ">>Neu.txt"); print DATEI @neu; close DATEI;
open (my $DATEI, '>>', "Neu.txt");
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
use v5.12; # strict inclusive use Text::CSV; my @rows; my $file = "Test.txt"; my $csv = Text::CSV->new ( { binary => 1, sep_char => "\t" } ) # should set binary attribute. or die "Cannot use CSV: ".Text::CSV->error_diag (); open my $IN, "<:encoding(utf8)", $file or die "$file: $!"; open (my $OUT, '>>', "Neu.txt"); while ( my $row = $csv->getline( $IN ) ) { say $OUT $row->[1],"\t", $row->[13]); } close $IN; close $OUT;
2015-10-28T17:49:56 azibCode (perl): (dl )1 2 3 4 5 6 7 8while (<IN>){ @a = split(/\t/, $_ ); } close(IN); foreach (0 .. $#a){ @neu = ($a[1], "\t", $a[13], "\n"); }
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
#!/usr/bin/perl use warnings; use strict; my $file = "Test.txt"; my @a; my @neu; my $in; my $datei; open($in, "<" , $file) or die "Datei $file konnte nicht gefunden werden\n"; while (<$in>) { chomp($_); @a = split(/\t/, $_); push(@neu, "$a[1]\t$a[13]\n"); } close($in); open($datei, ">", "Neu.txt"); foreach (@neu) { print $datei $_; } close($datei);