csv_splitter

csv_splitter is a simple Python3 script that takes a CSV as input and splits the contents into several smaller CSV files based on unique values of a given column.

Usage

python3 csv_splitter.py input split
  input : CSV file
  split : column to split by

Example

Let’s say we have CSV with a column titled gender, whose possible values are M and N. Passing the column name to csv_splitter results in two CSV files, M.csv and N.csvM.csv, containing all rows whose value for the gender column is M; and N.csv, containing all rows whose value for the gender column is N. The orginal CSV is kept intact.

Download

csv_splitter.py (1.3 KB)