CSV export from php big data

Source: Internet
Author: User
I now use php to export csv files, and then query the data in batches. then, the foreach loop writes a file in one row. after writing, execute the download method to download the file, my current problem is that if there is too much data, the php program is finished and the file is still being written ,... I now use php to export csv files, and then query the data in batches. then, the foreach loop writes a file in one row. after writing, execute the download method to download the file, my current problem is that if there is too much data, the php program has been executed and the file is still being written. the download method cannot be executed, so the file cannot be downloaded. Is there any way to solve this problem?

Reply content:

I now use php to export csv files, and then query the data in batches. then, the foreach loop writes a file in one row. after writing, execute the download method to download the file, my current problem is that if there is too much data, the php program has been executed and the file is still being written. the download method cannot be executed, so the file cannot be downloaded. Is there any way to solve this problem?

This data volume usually times out for a single php request.

We recommend that you use the php file to process only 10 pieces of data at a time, append the data to the csv file, and return the results quickly in a single request.

Then write a js program. ajax calls the php file cyclically until all data is processed, triggering the webpage download action. In this way, the front-end web page can display the processing progress in real time.

Because csv is essentially plain text, you can use JavaScript and php to initiate multiple requests to batch upload strings, and finally merge JavaScript to generate files (the link is in the form of data)

The file is not completely generated, and the button is disable.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.