I would like to use python to delete the header and the 1st row of a huge csv file (3GB) with good performance.
import csv
import pandas as pd
def remove2rows(csv_file):
data = pd.read_csv(csv_file)
data = data.iloc[1:]
data.to_csv(csv_file, header=None, index=False)
if __name__ == "__main__":
remove2rows(filename)
This script works but takes some time, probably because it reads the whole file and it writes every row starting from row 3 to the end of the file to a new csv file.
Is there any ways that can improve the performance?