Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write directory reader. #45

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/alogamous/directory_reader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Given a directory - assume everything in directory is a file
# Open every file in that directory
# Spit out lines until there are no more lines in files
import logging
import os


class DirectoryReader:
def __init__(self, directory):
self.directory = directory

def read(self):
for filename in os.listdir(self.directory):
with open(self.directory + "/" + filename) as f:
yield from f


if __name__ == "__main__":
reader = DirectoryReader("../../data")
for line in reader.read():
logging.info(line)
Loading