Python Forum

Full Version: Split excel file and write output at specific row and set sheet position
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,

I have a Masterfile which I split with the help of codes. Below is the code I use for splitting the excel file based on a column.

import pandas as pd #pip install pandas
import os

df = pd.read_excel('CE Version - Drewry December Masterfile - v5.xlsx')
column_name = 'Member Name'
unique_values = df[column_name].unique()

for unique_value in unique_values:
    df_output = df[df[column_name].str.contains(unique_value)]
    output_path = os.path.join('output',unique_value + '.xlsx')
    df_output.to_excel(output_path, sheet_name=unique_value, index=False) 
Question:- I want the data in splited files from row 17. Means top 16 rows should be empty in each splited files. And, I want to add one empty sheet as well in each splited files. How is it possible ?