difference in csv.reader and pandas - python difference in csv.reader and pandas - python pandas pandas

difference in csv.reader and pandas - python


Refer to the pandas.read_csv there is an argument named skip_blank_lines and its default value is True hence unless you are setting it to False it will not read the blank lines.

Consider the following example, there are two blank rows:

A,B,C,D0.07,-0.71,1.42,-0.370.08,0.36,0.99,0.111.06,1.55,-0.93,-0.90-0.33,0.13,-0.11,0.891.91,-0.74,0.69,0.83-0.28,0.14,1.28,-0.400.35,1.75,-1.10,1.23-0.09,0.32,0.91,-0.08

Read it with skip_blank_lines=False:

df = pd.read_csv('test_data.csv', skip_blank_lines=False)len(df)10 

Read it with skip_blank_lines=True:

  df = pd.read_csv('test_data.csv', skip_blank_lines=True)  len(df)  8