From 8555c7d6a78519ee0d95482d9cd52f67ebab3ee0 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 2 Oct 2026 09:17:12 -0500 Subject: Initialise module for common CSV processing utilities. --- uploader/csvprocessing.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 uploader/csvprocessing.py (limited to 'uploader/csvprocessing.py') diff --git a/uploader/csvprocessing.py b/uploader/csvprocessing.py new file mode 100644 index 0000000..3b46515 --- /dev/null +++ b/uploader/csvprocessing.py @@ -0,0 +1,31 @@ +"""Utilities for processing CSV files.""" +from typing import Callable + + +def is_blank_line(line: str) -> bool: + """Is the given line a blank line? + + :param line: The line to check for blankness. + :type line: str + :rtype bool + """ + return line.strip() == "" + + +def make_comment_line_checker(comment_char: str) -> Callable[[str], bool]: + """Make function that checks whether a line is a comment line. + + :param comment_char: The character indicating the line is a comment. + :type comment_char: str + :rtype Callable[[str], bool] + """ + def _is_comment_line_(line: str) -> bool: + """Check whether the line is a comment. + + :param line: The line to check. + :type line: str + :rtype bool + """ + return line.startswith(comment_char) + + return _is_comment_line_ -- cgit 1.4.1