Skip to content

Instantly share code, notes, and snippets.

@travleev
travleev / clean-csv.py
Created January 11, 2019 00:14
Python CSV filter: replaces repeating values in columns with spaces. Originally, used to clean csv files generated with multiindex pandas dataframe to_csv() method.
# Clean csv with multiindices
from sys import argv
# Command line arguments:
# original csv file
# number of columns to check (optional)
with open(argv[1], 'r') as f:
if len(argv) > 2:
n = int(argv[2])