Skip to content

ENH: Implement skiptrailingspace parameter for read_csv #60813

Open
@PythonDev803

Description

@PythonDev803

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

I was trying to read CSV files using the read_csv function. The most cumbersome part was not having an option to strip trailing spaces between values and separators. For initial spaces, we have the parameter skipinitialspace but a similar parameter for skiptrailingspace is missing.

Feature Description

Add a new parameter skiptrailingspace to the read_csv function. This parameter should function similar to skipinitialspace, but must be skipping trailing spaces.

Alternative Solutions

So far, I tried to fix this manually as follows:

df = df.map(
        lambda x: x.strip() if isinstance(x, str) else x
    )

This is rather slow - I expect a build-in functionality should be much quicker.

Additional Context

Issue #42054 suggests adding skiptrailingspace to the read_table function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNeeds TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions