Created
March 2, 2020 23:01
-
-
Save a-recknagel/e92864acd00a963c5aa6b6a8ae360aba to your computer and use it in GitHub Desktop.
rewrite 4th column
This file contains hidden or 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 | |
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