'Replace the header of csv without loading the whole csv in memory in PHP

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.



Solution 1:[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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tomáš Fejfar