Skip to content

ENH: startrow or skiprows in .to_csv #51190

@yasirroni

Description

@yasirroni

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

When writing to csv, sometimes we want to skip rows. The most useful use case is when someone want to write multiple dataframes in single csv files useing mode='a'. If pandas support skip rows, we can give an empty rows to the file. Later in reading, we can use a detect NaN as separator between tables.

I prefer skiprows than startrow as the most relevant use case is to skip rows and write from there.

Feature Description

def  to_csv(skiprows=N):
    # this feature works like read from first line, skipping N rows using readline, use write delimiter only in case no more read
    ...


def  to_csv(startrow=N):
    # this feature works by writing delimiter and change lines from the start N time.
    for i in range(N):
        write(f"{delimiter}\n)
    ...

Alternative Solutions

Additional Context

No response

Metadata

Metadata

Assignees

Labels

Closing CandidateMay be closeable, needs more eyeballsEnhancementNeeds 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