Skip to content

Instantly share code, notes, and snippets.

@a-recknagel
Created March 2, 2020 23:01
Show Gist options
  • Save a-recknagel/e92864acd00a963c5aa6b6a8ae360aba to your computer and use it in GitHub Desktop.
Save a-recknagel/e92864acd00a963c5aa6b6a8ae360aba to your computer and use it in GitHub Desktop.
rewrite 4th column
import csv
def main():
old_file = input('please give file name: ')
new_file = old_file + '.updated'
with open(old_file) as old, open(new_file, 'w') as new:
writer = csv.writer(new)
for row in csv.reader(old):
if row[4] == 'MIS':
row[3] = row[3].replace('.com', '.net')
writer.writerow(row)
print('wrote results to ' + new_file + ', replace ' + old_file + ' with it once you are sure everything is fine.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment