Skip to content

Instantly share code, notes, and snippets.

@rabbleNaut
Last active August 29, 2015 13:57
Show Gist options
  • Save rabbleNaut/9662976 to your computer and use it in GitHub Desktop.
Save rabbleNaut/9662976 to your computer and use it in GitHub Desktop.
Used for editing a .csv file that was too large for Excel or Access.
import csv
#removes columns starting at remove_from up to- but *not including* - remove_to
remove_from = 239
remove_to = 260
fp_in = open("tx000452010.txt", "rb")
fp_out = open("tx000452010_PT1.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 #counter and print for visual shell purposes only
x += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment