Created
March 20, 2014 12:46
-
-
Save rabbleNaut/9663009 to your computer and use it in GitHub Desktop.
Used for editing a .csv file that was too large for Excel or Access.
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 | |
# Removes columns starting at remove_from up to- but *not including* - remove_to | |
# In this example, all columns are removed except for the first 5 and last 21 | |
remove_from = 5 | |
remove_to = 239 | |
fp_in = open("tx000452010.txt", "rb") | |
fp_out = open("tx000452010_PT2.txt", "wb") | |
reader = csv.reader(fp_in, delimiter=",") | |
writer = csv.writer(fp_out, delimiter=",") | |
x = 1 | |
for row in reader: | |
del row[remove_from:remove_to] | |
writer.writerow(row) | |
print "Editing row: %s" % x | |
x += 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment