[BioMart Users] Saving Results of Perl query to file

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[BioMart Users] Saving Results of Perl query to file

manjulapra
Hi All,
I will be grateful if anybody can give a example showing how I can save the output of the Perl API query to a file. The "printResults()" only prints the results. How can I load it in to variable for further manipulation?
Sorry If this is too basic. But I tried but could not find a way.
Thanking in advance,

Manjula

_______________________________________________
Users mailing list
[hidden email]
https://lists.biomart.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: [BioMart Users] Saving Results of Perl query to file

Junjun Zhang
Hi Manjula,

There are two simple ways to output the Perl API query result into a file.

  • Using I/O redirection. 
perl myPerlAPI.pl > my_query_results.txt
  • Using filehandle in Perl. The printResults() method (as well as printHeader() and printFooter()) takes an optional filehandle as argument. It works like this:
use IO::File; # add this to the beginning of your script

my $fh = IO::File->new("> my_query_results.txt"); # create a new filehandle

$query_runner->printHeader($fh); # output header to the file
$query_runner->printResults($fh); # output the results to the file
$query_runner->printFooter($fh); # output the footer to the file
$fh->close; # close the file

Hope this helps,

Junjun




From: Manjula Dharmawardhana <[hidden email]>
Date: Wed, 27 Jul 2011 03:24:15 -0400
To: "[hidden email]" <[hidden email]>
Subject: [BioMart Users] Saving Results of Perl query to file

Hi All,
I will be grateful if anybody can give a example showing how I can save the output of the Perl API query to a file. The "printResults()" only prints the results. How can I load it in to variable for further manipulation?
Sorry If this is too basic. But I tried but could not find a way.
Thanking in advance,

Manjula

_______________________________________________
Users mailing list
[hidden email]
https://lists.biomart.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: [BioMart Users] Saving Results of Perl query to file

manjulapra
Thank you very much,
You saved my day!
Thank you again, It worked.

Regards,
Manjula

On Thu, Jul 28, 2011 at 3:10 AM, Junjun Zhang <[hidden email]> wrote:
Hi Manjula,

There are two simple ways to output the Perl API query result into a file.

  • Using I/O redirection. 
perl myPerlAPI.pl > my_query_results.txt
  • Using filehandle in Perl. The printResults() method (as well as printHeader() and printFooter()) takes an optional filehandle as argument. It works like this:
use IO::File; # add this to the beginning of your script

my $fh = IO::File->new("> my_query_results.txt"); # create a new filehandle

$query_runner->printHeader($fh); # output header to the file
$query_runner->printResults($fh); # output the results to the file
$query_runner->printFooter($fh); # output the footer to the file
$fh->close; # close the file

Hope this helps,

Junjun




From: Manjula Dharmawardhana <[hidden email]>
Date: Wed, 27 Jul 2011 03:24:15 -0400
To: "[hidden email]" <[hidden email]>
Subject: [BioMart Users] Saving Results of Perl query to file

Hi All,
I will be grateful if anybody can give a example showing how I can save the output of the Perl API query to a file. The "printResults()" only prints the results. How can I load it in to variable for further manipulation?
Sorry If this is too basic. But I tried but could not find a way.
Thanking in advance,

Manjula



--


This communication (including any attachments) is intended for the use of the intended recipient only and may contain information that is confidential, privileged or legally protected. Any unauthorized use or dissemination of this communication is strictly prohibited. If you have received this communication in error, please immediately notify [hidden email] by return e-mail message and delete all copies of the original communication. Thank you for your cooperation.



_______________________________________________
Users mailing list
[hidden email]
https://lists.biomart.org/mailman/listinfo/users