Python Advanced #8 - Reading One Column from a Justified Text File and Writing to a New File

In this post, we start with a justified text file as shown below.  This file is titled justified.txt.



Our objective is to extract the middle value and write those values to a different text file.  We do this by using the code below.

We first open the file and then read each line.  As each line is read, we extract the middle value and append it to the list named vals.  Once that is completed, we create a new text file titled justextract.txt and write each value in the list to this file with each value appearing on a separate line.



The results of this program are shown below.

Comments