Cody Bable

Generation

generate functionMon, 24 Apr 2023

read from source file one line at a time and write to target file one line at time.

source_file = open('source.txt', 'r') target_file = open('target.txt', 'w') def read_line(source_file, target_file): source_line = source_file.readline() if source_line == '': return else: target_file.write(source_line) read_line(source_file, target_file) read_line(source_file, target_file) source_file.close() target_file.close()

Questions about programming?Chat with your personal AI assistant