how can i import in Matlab text file using PERL script?

90 Views Asked by At

i try to import huge text file (~5 million lines). I try with this script

aaa = perl('importFile.pl',fileName);

where "importFile.pl" is

use strict;
use warnings;
    while (my $row = <>) {
      chomp $row;
      print "$row\n";
    }

but nothing happens!. what is my mistake??? Or can you suggest similar (and fast) solution?

Matlab R2014a 64bit

1

There are 1 best solutions below

1
LazyTitan On

Iam not super familiar with perl but have worked with it alittle in the past.I'm guessing there is an issue with your loop, but like I stated i'm not a perl monk! Here is a program I used to read from a file and prints it:

#!/usr/bin/perl

use strict;
use warnings;

#Opens a file handler
open my $fh, '<', '/home/user/Desktop/ScriptForChangesets/ToBeRead.txt' or die "Can't open file";

#Prints the file contents
print do{local $/; <$fh>};

Hope this helps!