diff --git a/documents/references.md b/documents/references.md index 764a3d6145d228254877d7d893bf2f4d24154649..b8130606fdd872a4903fd665338faa15817fe220 100644 --- a/documents/references.md +++ b/documents/references.md @@ -5,7 +5,9 @@ All references to external logic. Includes anything from stack overflow links to notes about logic from previous works. -## Logging Logic +## Python + +### Logging Logic The contents of `resources/logging.py` (and all associated logic) originally started from me trying to learn how to log information through Django (the Python Web Framework) using a Dictionary type format. (See <https://docs.djangoproject.com/en/dev/topics/logging/> for reference). @@ -15,3 +17,6 @@ and school assignments. After repeatedly importing and updating as needed, the l what it is today. Logging files can be found in `resources/logs/`. + +### Reading Files +<https://www.pythonforbeginners.com/files/reading-and-writing-files-in-python> diff --git a/main.py b/main.py index 672e0e4796c0ef8706b2cd683543c87a3137fb1c..ed3f932fff7e15d5fcfffed45021645b5934967a 100644 --- a/main.py +++ b/main.py @@ -14,8 +14,35 @@ logger = init_logging.get_logger(__name__) def main(): + """ + Program main. + """ logger.info('Starting main()') + calc_part_1() + + +def calc_part_1(): + """ + Logic for "part 1" of assignment. + """ + student_array = [] + + # Open file. + with open('./documents/data.online.scores.txt', 'r') as student_scores_file: + # Read in each line and save to our struct. + for line in student_scores_file: + # Split on tabs. + split_line = line.strip().split('\t') + + # Save to struct. + student_array.append({ + 'id': int(split_line[0]), + 'midterm': int(split_line[1]), + 'final': int(split_line[2]), + }) + + logger.info(student_array[len(student_array) - 1]) if __name__ == '__main__':