Skip to content
Snippets Groups Projects
Commit 6e8d72a6 authored by Brandon Rodriguez's avatar Brandon Rodriguez
Browse files

Implement initial read in of file

parent 20656f1e
Branches
No related merge requests found
......@@ -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>
......@@ -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__':
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment