Feature Type

  • [x] 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.

Comment From: tsafacjo

Can I worked on it ?

Comment From: quangngd

@tsafacjo I'd wait until a decision is made by a pandas team member

Comment From: PythonDev803

Is there any update on this? I can help with anything?