I would like to know what is the fastest and more efficient way of deleting last N lines of a .txt file.
I have been looking for different previous questions and I found that reading and copying lines again is one way.
Remove lines from textfile with python
Nonetheless, I have been trying to look for other way such as skiprows or skipfooter on pandas and be able to save the outcome to other txt.
At the same time, I have seen threads about "head" and "sed" but not sure about their usage in Python.
Could you, please, give advice on this topic?