Skip to content

ENH: skiprows after header in read_csv #58870

@davetapley

Description

@davetapley

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

There isn't a way to tell read_csv to skiprows after the specified header row.

Feature Description

To avoid breaking existing logic, I think a new argument would be required, perhaps skiprows_after?

So one could, parse, for example:

ignore,me
foo,bar
ignore,me
123,1
456,2

with read_csv(f, header=1, skiprows_after=1) and get:

   foo  bar
0  123    1
1  456    2

Alternative Solutions

Workaround:

header = read_csv(f, skiprows=1, nrows=1)
names = header.columns.to_list()
read_csv(f, skiprows=4, names=names)

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementIO CSVread_csv, to_csvNeeds DiscussionRequires discussion from core team before further action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions