CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: DBI:
in perl dbi How To Generate CSV for 1 lakh record of my Query

 



dashang.trivedi
Novice

May 11, 2011, 2:34 AM

Post #1 of 3 (10385 views)
in perl dbi How To Generate CSV for 1 lakh record of my Query Can't Post

Hello EveryOne,

My Objective is to generate CSV file of my query output.
if my table have 1 Lakh record...
i am using this way

Code
open(CSV, "> file.csv"); 
$sth = $dbh->prepare('SELECT * FROM exmpl_tbl ');
$sth->execute();
while($result = $sth->fetchrow_hashref()) {
print CSV "$result->{id} , $result->{val} \n";
}

close(CSV);


This way is not optimize way to generate CSV...
how to generate CSV for 1 lakh record or more in fast way....

so please suggest me .....


(This post was edited by dashang.trivedi on May 11, 2011, 2:38 AM)


miller
User

May 11, 2011, 11:31 AM

Post #2 of 3 (10372 views)
Re: [dashang.trivedi] in perl dbi How To Generate CSV for 1 lakh record of my Query [In reply to] Can't Post

Why is the method you're using not fast enough?

Looks fine to me, although I'd advise using Text::CSV for processing csv files.

- Miller


dashang.trivedi
Novice

May 12, 2011, 8:10 AM

Post #3 of 3 (10348 views)
Re: [miller] in perl dbi How To Generate CSV for 1 lakh record of my Query [In reply to] Can't Post

Thank you miller i got the solution ......i m new to perl dbi...
i don't know about Text:CSV module...
its work like magic .....

thank you very much sir.......

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives