Search code examples
pythonpandasvalueerror

Remove Semicolons as Line Delimiters Reading csv-file Using pandas.read_csv


I'm working with a pandas dataframe that I want to plot. Instead of being float numbers, some values inside the dataframe are strings because they have a semicolon. This causes a ValueError when the dataframe is to be plotted. I have found out that the semicolons only occur at the end of each line.

Is there a keyword in the read_csv method to let pandas recognize the semicolons so they can be removed?


Solution

  • If the semicolon is being used to separate lines, you can use the lineterminator parameter to correctly parse the file:

    pd.read_csv(..., lineterminator=";")
    

    Pandas CSV documentation