How to split a list into multiple lists?

Splitting a List into Multiple Lists

If you deal with data as part of your business, you must have stumbled upon this problem every now and then. Many of you look for a solution in Excel or Googlesheets, but a solution in Python is a lot more convenient, especially when you have access to online spaces like Jupyter Notebooks or Google Colab.

Problem Statement

Split a spreadsheet into different spreadsheets based on a column in the spreadsheet.

Input

A CSV file consisting of all data.

Output

1. Separate Lists as Multiple CSVs.
2. Single Excel (XLSX) file with Multiple tabs.

Steps

1. Enter the name of the input file.
2. Select the column you want to use to split the file.
3. Select the output format (CSV or XLSX).
4. If output format is CSV, look for CSV files named after values in the column used for splitting the file.
5. If output format is XLSX, look for an XLSX file with tabs named after values in the column used for splitting the file.

In case you’re interested in this script, developed using Python, just reach out!

Output Samples

  1. CSV: Multiple CSV files, one for each list.
Enter file to be split: List.csv

Select the index corresponding to the column you want to use to split the file:
0 - Customer ID
1 - Name
2 - Email
3 - Address
4 - Domain
5 - Owner

Select the index: 5

File List.csv will be split using Owner as splitter.

Output Format:
0 - CSV
1 - XLSX
Pick the output file type: 0

Input file List.csv will be split into multiple CSVs named as: 
Archie.csv
Betty.csv
Veronica.csv

2. XLSX: A single Excel spreadsheet with multiple tabs, one for each list.

Enter file to be split: List.csv

Select the index corresponding to the column you want to use to split the file:
0 - Customer ID
1 - Name
2 - Email
3 - Address
4 - Domain
5 - Owner

Select the index: 5

File List.csv will be split using Owner as splitter.

Output Format:
0 - CSV
1 - XLSX
Pick the output file type: 1

Input file List.csv will be split into multiple tabs in Output.xlsx with the following sheet names: 
Archie
Betty
Veronica

Hit the subscribe button below if you would like to be notified about such new posts.

One thought on “Splitting a List into Multiple Lists

Leave a Reply to Splitting a List into Multiple Lists – Be Nimble – Medium | Coding Videos Cancel reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s