Skip to content

Instantly share code, notes, and snippets.

@nadya-p
nadya-p / pdf_to_text.py
Last active August 15, 2022 04:42
Extract text contents of PDF files recursively
from tika import parser
import os
def extract_text_from_pdfs_recursively(dir):
for root, dirs, files in os.walk(dir):
for file in files:
path_to_pdf = os.path.join(root, file)
[stem, ext] = os.path.splitext(path_to_pdf)
if ext == '.pdf':
@nadya-p
nadya-p / settings.py
Last active June 12, 2024 19:39
Simple Python settings class using JSON file as storage
import json
import os
class Settings:
_config_location = 'config.json'
def __init__(self):
if os.path.exists(self._config_location):
self.__dict__ = json.load(open(self._config_location))