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 8626911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:08:42+00:00 2026-06-12T08:08:42+00:00

I have a large csv file (around 700MB) that I am trying to parse

  • 0

I have a large csv file (around 700MB) that I am trying to parse and insert into a MySQL database. I read the csv (around 4×10^6 rows) line by line and parse the records to insert. I then insert the records into the database in batches of about 10k records per batch. There are a few things during parsing, e.g. converting a duration of format 11d 12:34:56 into number of hours using preg_match.

preg_match('/(?P<days>\d+)d (?P<hours>\d+)?P<minutes>\d+)?P<seconds>\d+)/', $hoursUsed, $matches);

The script takes about 40 minutes to completely parse the file and insert all records into the database. The questions that I have here are:
* What should be expected time? I wonder if 40 minutes is normal or not?
* Could the parsing of the csv file be

I am parsing a file(csv) of size around 700MB in PHP (around 4×10^6 rows) but it is taking around 40 minutes to parse the file. I am trying to optimize the parsing but only able to optimize it from 45 to 40 minutes. My questions are:

  • What should be expected time? I wonder if 40 minutes is normal or not?
  • I do this with the request so there is no response until the file is completely parsed and everything is inserted. Is there a better way to delegate this to an asynchronous process?

FYI I am using CakePHP.

  • 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-06-12T08:08:43+00:00Added an answer on June 12, 2026 at 8:08 am

    Using LOAD DATA INFILE would speed things up considerably. Just load the duration value in a CHAR field and let MySQL process it later.

    That way, you leave the data processing to the database, which will be significantly faster than PHP.

    Further, 40 minutes sounds not too bad for 700MB and 4 million records. Of course it all depends on the code, the machine, etc.

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

Sidebar

Related Questions

I am trying to import a large CSV file into a MySQL database. I
I have a very large CSV file that I imported into a sqlite table.
I'm trying to import a very large .csv file (~4gb) into mysql. I was
I have a very large .csv file, and I'm loading it into mysql with
I am trying to take a rather large CSV file and insert it into
I am trying to import a large csv file into MySQL. It's about 1.4
I have a large number of records (around 40,000) in a csv file to
I have a large CSV data file -- ~1,444,000 rows of data -- that
I have a large CSV file that contains independent items that take a fair
I have a very large csv file that looks like this: keywords,impressions descargar juegos

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.