Search code examples
python-3.xpandascsvpandas-datareader

Pandas: How to import CSV without the sep="," present at the top of the csv


I want to import CSV with pandas. The problem that I have with my CSV is that it has the sep= "," present in the top column, in a few files, due to which the data frame is not constructed properly.

Example: 
sep = ,
  Year Dec Jan
     1  50  60
     2  25  50
     3  30  30
     4  40  20
     5  10  10

Note: The separator is ALWAYs going to be a ",". I just want it to get removed when I covert the csv to a dataframe.


Solution

  • Try using skiprows in pandas.read_csv().

    From pandas documentation:

    skiprowslist-like, int or callable, optional Line numbers to skip (0-indexed) or number of lines to skip (int) at the start of the file.