D
D
Dmitriy2021-04-15 00:24:00
PHP
Dmitriy, 2021-04-15 00:24:00

How to import CSV 300k rows in Laravel?

I am using laravel-excel lib.
Network file of 130 MB and 300k lines, you need to add it to the database.
I decided to do it through queues, but the problem is that when I load this file, the sled read does not work and, accordingly, does not add it to the database.
If you upload a file with fewer lines, then everything works.
How can I download such a file?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DevMan, 2021-04-15
@dmitriyuvin

umm.... why do you need laravel-excel to import csv?
take the package from the league and read line by line. I import them millions of lines every day, without any queues.
https://csv.thephpleague.com/

1
12rbah, 2021-04-15
@12rbah

If you upload a file with fewer lines, then everything works.
Read into memory not the entire file at once, but for example 10k lines. But in general, csv is just a text file (this is to the fact that excel and csv are very different inside). with a separator between lines, you can write your own solution, which will not be difficult to implement

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question