[Solved] How to extract specific columns in log file to csv file

You would probably need to use a regular expression to find lines that contain the values you want and to extract them. These lines can then be written in CSV format using Python’s CSV library as follows: import re import csv with open(‘log.txt’) as f_input, open(‘output.csv’, ‘w’, newline=””) as f_output: csv_output = csv.writer(f_output) csv_output.writerow([‘Iteration’, ‘loss’]) … Read more