I am reading a csv file in pandas, and I am skipping some bad lines / rows with:
df2 = pd.read_csv("Test.csv", sep=';', engine='python', error_bad_lines=False)
How can I count the total number of skipped rows in python?
How can I count this?
You could calculate the row difference:
with open("test.csv") as f:
len_csv = sum(1 for line in f)
number_of_skipped_rows = len_csv - len(df2)
f = open("Test.csv")
row_count= len(f.readlines())
df2 = pd.read_csv("Test.csv", sep=';', engine='python', error_bad_lines=False)
Count of skipped rows
skipped_rows = row_count - df2.shape[0]
df1 = pd.read_csv("Test.csv", sep=';', engine='python'), while give an error.