Split excel file and write output at specific row and set sheet position - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: Split excel file and write output at specific row and set sheet position (/thread-37208.html) |
Split excel file and write output at specific row and set sheet position - DSCA - May-12-2022 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 ? |