diff --git a/main.py b/main.py index 614f1ca94d4f49f4e3bab6d556552844b185d786..053ecdf9f8fe9e89ec4535e5bbb2e093037a9bf1 100644 --- a/main.py +++ b/main.py @@ -19,8 +19,6 @@ def main(): """ Program main. """ - logger.info('Starting main()') - calc_part_1() calc_part_2() calc_part_3() @@ -273,6 +271,50 @@ def calc_part_3(): logger.info('=========================') logger.info('') + lib_array = [] + + # Open file. + with open('./documents/data.libraries.inventories.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') + + # Loop through all line values. + for line_val in split_line: + + # Handle for each major case. + if line_val.strip() == 'library': + data_type = 1 + index = 0 + elif line_val.strip() == 'CML': + data_type = 2 + index = 0 + elif line_val.strip() == 'CBL': + data_type = 3 + index = 0 + else: + # Handle general case. + if data_type == 1: + # Is book id. + lib_array.append({ + 'id': int(line_val.strip().split('_')[1]) + }) + elif data_type == 2: + # Is CML library data. + lib_array[index]['CML'] = int(line_val.strip()) + index += 1 + elif data_type == 3: + # Is CBL library data. + lib_array[index]['CBL'] = int(line_val.strip()) + index += 1 + + logger.info('') + logger.info('Lib Array:') + for item in lib_array: + logger.info(' {0}'.format(item)) + logger.info('') + def calc_part_4(): """