Hi Charles,

Thanks a LOT.

I am trying to learn the CSV mode for the future, but this software will always 
spit the same file format at me, so your solution may be the way to go for now. 
Would you mi d giving me a quick explanation on what that one liner does? It be 
useful for me to learn it in more depth and be to adapt it to future problems.

Cheers,

Tiago

Sent from my iPad

On 2011-07-13, at 4:48 PM, "C.DeRykus" <dery...@gmail.com> wrote:

> 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/
> 
> 

--
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