Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1838024
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:25:38+00:00 2026-05-17T06:25:38+00:00

Am exporting data to csv. after 25000 records , memory exhausted. Memory limit increasing

  • 0

Am exporting data to csv. after 25000 records , memory exhausted.
Memory limit increasing is ok.

If i have 100000 rows, can i write it as 4 process.
write first 25000 rows, then next 25000 then next…

Is this possible in csv export?
Will this have any advantage? Or this is same exporting whole data?

Any multiple processing or parallel processing have some advantage?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T06:25:38+00:00Added an answer on May 17, 2026 at 6:25 am

    Well, this depends on how you’re generating the CSV.

    Assuming that you’re doing it as the result of a database query (or some other import), you could try streaming instead of building and then returning.

    Basically, you turn off output buffering first:

    while(ob_get_level() > 0) {
        ob_end_flush();
    }
    

    Then, when you’re building it, echo it out row by row:

    foreach ($rows as $row) {
        echo '"'.$row[0].'","'.$row[1].'"'."\n";
    }
    

    That way, you’re not using too much memory in PHP.

    You could also write the data to a temporary file, and then stream that file back:

    $file = tmpfile();
    foreach ($rows as $row) {
        fputcsv($file, $row);
    }
    rewind($file);
    fpassthru($file);  // Sends the file to the client
    fclose($file);
    

    But again, it all depends on what you’re doing. It sounds to me like you’re building the CSV in a string (which is eating all your memory). That’s why I suggested these two options…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm exporting data from python with the csv library which works pretty good. After
I am programmatically exporting data (using PHP 5.2) into a .csv test file. Example
i am exporting data to csv, while exporting i want to split by every
Exporting some data from mysql to a csv file using FasterCSV. I'd like the
I am working on exporting a data.frame to a csv for use in an
am exporting huge data to excel using php. i change that to csv and
When exporting a lot of data to a string (csv format), I get a
I'm exporting data programatically from Excel to SQL Server 2005 using SqlBulkCopy. It works
In ASP.NET, I am exporting some data to Excel by simply binding a DataSet
I needed to re-install my computer but I didn't think about exporting the data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.