Skip to content
This repository has been archived by the owner on May 26, 2024. It is now read-only.

Commit

Permalink
basics work
Browse files Browse the repository at this point in the history
  • Loading branch information
hirusha-adi committed Jan 20, 2024
1 parent 848ef3a commit d6b9394
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import os
from docx import Document

def search(fpath, target):
try:
doc = Document(fpath)
for paragraph in doc.paragraphs:
if target in paragraph.text:
return True
return False
except Exception as e:
print(e)
return False

def main():
target = "hirusha"
cwd = os.getcwd()
for fname in os.listdir(cwd):
if fname.endswith(".docx"):
fpath = os.path.join(cwd, fname)
if search(fpath=fpath, target=target):
print("Found in ", fname)
else:
print("Not found in ", fname)

if __name__ == "__main__":
main()

0 comments on commit d6b9394

Please sign in to comment.