Created
November 28, 2019 10:02
-
-
Save gpolitis/7371d998658bba57b805bfed5c7ce764 to your computer and use it in GitHub Desktop.
Python script that efficiently drops columns from a CSV file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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