On Jul 13, 9:59 am, tiago.h...@gmail.com (Tiago Hori) wrote:
> Hi All,
>
> I work with microarrays and get huge tab delimited files as outputs from the
> software that analysis these microarrays. The result is a tab-delimted Excel
> type of file that has 160000 rows and about 20 columns.
>
> Every 44K rows make one unit within the data. These units are identified by
> the Second data column, called meta arrow. So the first 44K rows have the
> value 1 on Meta row, the next 44K have the value 2 and so for.
>
> I would like to be able to separate these files into 4 different files, each
> one containing each unit of data. So all the rows that have meta row 1 would
> go to one file, and the ones with meta row 2 would go to another file and so
> forth.
>
> I have been reading beginning perl to tried to figure this out, but I
> haven't be able to come up with anything.
>
> I have many questions: I know I can use a filhandle to connect to the file,
> but how would I store the data to begin with?
>
> Is there a way to iteratively read through the rows and then copy them to a
> variable as long as their metarow column read let's say 1? and then out put
> that as a new file?
>

There's already been a very good recommendation. But, if
you know your file has no irregularities, is surprise-free as
far as formatting,  you may be tempted to just try a 1-liner
since Perl does make "easy things easy...":

perl -lane 'if ($F[1] ne $old ) {open($fh,'>',$F[1]) or die $!};
                   print $fh $_;$old = $F[1]'   file

--
Charles DeRykus


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to