MarthaF
MarthaF

Reputation: 187

How to write to CSV starting at row x?

Trying to do the opposite of :

read_csv(file, skiprows = 2)

Like :

df.to_csv(file, skiprows = 30)

A simple df.to_csv will print all data starting from row 1. How to start printing at row 30? I want to print starting at row 30 into CSV.

Upvotes: 2

Views: 2143

Answers (2)

MarthaF
MarthaF

Reputation: 187

Answer to this would be :

df.to_excel(writer,index=True,header=True,sheet_name='Sheet1',startrow=25,startcol=1) 

Upvotes: 1

DYZ
DYZ

Reputation: 57033

Just select the remainder of the dataframe after the first 30 rows:

df.iloc[30:].to_csv(file)

Upvotes: 3

Related Questions