Created
August 10, 2017 22:33
-
-
Save domarps/ca65bb04d82e2d14cc3b7dc7d2f61996 to your computer and use it in GitHub Desktop.
snippet to remove files
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
def remove_blacklisted_lines(): | |
with open('some.csv') as oldfile, open('some.csv', 'w') as newfile: | |
for line in oldfile: | |
ss = line.split('_') | |
if not any(t in ss[-2] for t in remove_urls): | |
newfile.writr(line) | |
import glob | |
import os | |
rem_list = ['2', '4'] | |
for item in rem_list: | |
print(item) | |
for path in glob.glob('foo_*.txt'): | |
if item in path: | |
os.remove(path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment