0

I have an excel file with huge dataset. I tried to read the excel file using the below command using pandas.

df = pd.read_csv(f'{cwd}/data.csv', keep_default_na=False, header=None)
print(df)

However the empty rows found in the csv file is missing in the output. I get something like below.

Input:       Output from the code:
    1               1
    2               2
    3               3
                    4
    4               5         
    5               6               
    6
Balash
  • 67
  • 4

1 Answers1

0

You need to specify the parameter skip_blank_lines=False from pandas.read_csv. Here's a fixed version of your code:

import pandas as pd

df = pd.read_csv(f'{cwd}/data.csv', header=None, na_filter=False, skip_blank_lines=False)
df

Outputs:

enter image description here

Or:

import pandas as pd

df = pd.read_csv(f'{cwd}/data.csv', header=None, skip_blank_lines=False)
df

Outputs:

enter image description here

Ingwersen_erik
  • 1,701
  • 1
  • 2
  • 9