#!/usr/bin/env python3 import sys import os from pathlib import PureWindowsPath path = sys.argv[1] def getImportDate(line): date = line.lstrip('') date = date.rstrip('\n') return int(date) def getCreateDate(line): date = line.lstrip('') date = date.rstrip('\n') return int(date) f = open(in_file, "r") lines = f.readlines() f.close() for lnum,line in enumerate(lines): if '' in line: import_date = getImportDate(line) date_imported_line = lnum elif '' in line: create_date = getCreateDate(line) if create_date < import_date: print(import_date, create_date) lines[date_imported_line] = f'{create_date}\n' f = open(out_file, 'w') f_string = "".join(lines) f.write(f_string) f.close() exit()