From 776eee00928266013c9dc4ca94c8f43b816183e2 Mon Sep 17 00:00:00 2001 From: Daniel Tschertkow Date: Sun, 22 Nov 2020 16:21:53 +0100 Subject: [PATCH] =?UTF-8?q?f=C3=BCgt=20libex01.py=20hinzu.=20Enth=C3=A4lt?= =?UTF-8?q?=20read=5Fplaintext?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libex01.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/libex01.py diff --git a/src/libex01.py b/src/libex01.py new file mode 100644 index 0000000..97ac0d3 --- /dev/null +++ b/src/libex01.py @@ -0,0 +1,14 @@ +# file: read_plaintext.py +# module to read plaintext from a file into a string variable. +# Skips non-alphabetic characters and converts the rest to lower case + +import string + +def read_plaintext(file_path): + txt = "" + with open(file_path, "r") as _file: + for line in _file: + for char in line: + if char in string.ascii_letters: + txt += char + return txt