Skip to content

Instantly share code, notes, and snippets.

@RayBB
Created January 24, 2022 00:18
Show Gist options
  • Save RayBB/db8e586e4403b1c6c471cbb3beed413b to your computer and use it in GitHub Desktop.
Save RayBB/db8e586e4403b1c6c471cbb3beed413b to your computer and use it in GitHub Desktop.
import os
import re
def findfiles(path, regex):
regObj = re.compile(regex)
res = []
for root, dirs, fnames in os.walk(path):
for fname in fnames:
if regObj.match(fname):
res.append(os.path.join(root, fname))
return res
def grep(filepath, word):
res = []
with open(filepath) as f:
for line in f:
if word in line:
res.append(line)
return res
files = findfiles('./data/brands', '')
def word_in_files(word):
for f in files:
found = grep(f, word)
if found:
#print(found)
return True
return False
with open('regional.txt') as file:
lines = file.readlines()
lines = [line.rstrip() for line in lines]
missing = []
for word in lines:
if not word_in_files(word):
missing.append(word)
print("MISSING")
print("\n".join(missing))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment