Created
July 26, 2018 12:50
-
-
Save rathankalluri/14eafdad3714498e927f59eb07d32665 to your computer and use it in GitHub Desktop.
Remove row from CSV and store into New
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 os | |
src = 'Users.csv' | |
dst = 'Users_new.csv' | |
with open(src, 'rb') as inp, open(dst, 'wb') as out: | |
writer = csv.writer(out) | |
reader = csv.reader(inp) | |
next(reader, None) | |
for row in reader: | |
if row[7] != 'DND': #Checking the value in the row | |
writer.writerow(row) | |
os.remove(src) | |
print "Original File Deleted" | |
os.rename(dst, src) | |
print ("File renamed") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment