Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

varovas's avatar

Importing large CSV or TXT Files

Hi guys, maybe some of you can share your experience, tips or tricks about best practices when uploading CVS or TXT files with 500k or more rows and import the data to MySQL database? Code samples are extremely welcome.

0 likes
1 reply
ZetecVan's avatar

There is this that will help you import CSVs: http://www.maatwebsite.nl/laravel-excel/docs/import

I've not worked with it, although I did look at it for something I was going to do.

One of my projects imports an XML file with 26,000 rows. For that I parse the XML, and read though it. For every record I fire off a job that saves it to the database. It only takes a few seconds for the 26000 rows to be read, then the records are saved in the background.

Please or to participate in this conversation.