This repository contains python code to split data in an excel workbook (for all worksheets) into multiple excel files based on column value.
Table of Contents
This project contains the utility to split an excel workbook (.xlsx) into multiple excel workbooks based on the column value. The source excel file can have multiple worksheets. All worksheets must have first row for column headers.
The utility looks for unique values of the filter column across all worksheets and then create new workbook (e.g. Split-{Value1}.xlsx) for each unique value such that the newly generated excel workbook has records only for filtered value (e.g. Value1). The utility also copies the cell format from source excel workbook to all destination workbook.
This utility is build using
To get a local copy up and running follow these simple example steps.
In order to run the utility on your local, you need to follow below-mentioned steps.
-
Python
Download and install python from here
-
Clone the repo
git clone https://github.com/ParakhMittal/split-excel.git
-
Set the location of installation directory (e.g. C:\Program Files\Python38) of Python in the environment variable PATH.
-
Set the location of installation directory (e.g. C:\Program Files\Python38\Scripts) of Python in the environment variable PATH.
-
Install pipenv
pip install pipenv
-
Create the virtual environment
pipenv --three
-
Install dependencies
pipenv install
-
Activate the virtual environment (created by pipenv)
pipenv shell
-
Run the utility
python -m SplitExcel.py <src_file> <filter_col_name> <des_directory>
-
Exit the virtual environment.
exit
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/my-feature-branch
) - Commit your Changes (
git commit -m 'Add some feature'
) - Push to the Branch (
git push origin feature/my-feature-branch
) - Open a Pull Request