I have a CSV of size 5GB and more. I need to replace the header of the CSV with one different header string. I am looking for a memory-efficient solution in PHP
where I won't need to read the whole CSV in memory just to replace the header.
Asked
Active
Viewed 83 times
0

Mukul Kumar
- 564
- 1
- 5
- 24
-
1try [league/csv](https://csv.thephpleague.com/) – Molod Mar 10 '22 at 07:31
-
Does this answer your question? [Replacing a line in a file without rewriting the entire file (in PHP)](https://stackoverflow.com/questions/10030804/replacing-a-line-in-a-file-without-rewriting-the-entire-file-in-php) – CBroe Mar 10 '22 at 08:04
1 Answers
1
Honestly I would use some combination of head&tail&echo in bash running in symfony/process
. That's usually safest and most memory efficient.

Tomáš Fejfar
- 11,129
- 8
- 54
- 82