Skip to content

Instantly share code, notes, and snippets.

@gpolitis
Created November 28, 2019 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gpolitis/7371d998658bba57b805bfed5c7ce764 to your computer and use it in GitHub Desktop.
Save gpolitis/7371d998658bba57b805bfed5c7ce764 to your computer and use it in GitHub Desktop.
Python script that efficiently drops columns from a CSV file
import csv
import sys
START = 0
STOP = 1
STEP = 1
# adjust the constants and then use like this:
# cat CSV_FILE | python csvio.py | less -S
writer = csv.writer(sys.stdout)
for row in csv.reader(iter(sys.stdin.readline, '')):
writer.writerow(row[START:STOP:STEP])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment