You will need to rewrite the whole file. Simplest is not to use python
echo 'col1, col2, col2,... ' > out.csv
cat in.csv >> out.csv
Python based solutions will work at much higher levels and will be a lot slower. 18GB is a lot of data after all. Better to work with operating system functionality, which will be the fastest.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…