Skip to content

Instantly share code, notes, and snippets.

@domarps
Created August 10, 2017 22:33
Show Gist options
  • Save domarps/ca65bb04d82e2d14cc3b7dc7d2f61996 to your computer and use it in GitHub Desktop.
Save domarps/ca65bb04d82e2d14cc3b7dc7d2f61996 to your computer and use it in GitHub Desktop.
snippet to remove files
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