title: How to iterate through rows from multiple text files and extract values in a table.
body: <p>I am making a script to iterate through multiple log files and want to extract information from certain rows and display it as a formatted table for checking all the values , rows from the first column to be used as column names and the values appended to these columns.</p>
  
  <p>file_1:</p>
  
  <pre><code>   TRACE HEADER=========================================
                      min max
     col_1 [001-004]: 42  55
     col_2 [001-005]: 34  58
     col_3 [001-006]: 94  51
     col_4 [001-007]: 43  27
     col_5 [001-008]: 14  95
     -------------------------------------
  </code></pre>
  
  <p>file_2:</p>
  
  <pre><code>   TRACE HEADER=========================================
                      min max
     col_1 [001-004]: 43  55
     col_2 [001-005]: 39  58
     col_3 [001-006]: 91  51
     col_4 [001-007]: 48  25
     col_5 [001-008]: 14  96
     -------------------------------------
  </code></pre>
  
  <p>I have already tried iterating through the rows to extract the first column of the text file as column headers and extracting the other values as a list .</p>
  
  <pre><code>import re 
  file = "f.txt"
  
  
  TRC_BEGIN = "TRACE HEADER==="
  TRC_END = "---------------"
  
  col_names = []
  
  istrace = False
  traceLineCount = 0
  
  log = open(file, "r")
  
  for line in log:
  
      if line.startswith(TRC_BEGIN):
          istrace = True
      if istrace:
         traceLineCount = traceLineCount + 1
      if istrace and traceLineCount &gt; 2:
         col = re.split("\[\d\d\d\-\d\d\d\]:\s", line)
         #print(col)
         col_1= col[0].strip()
         col_names.append(col_1)
     if line.startswith(TRC_END):
         istrace = False
  
  del col_names[-2:]
  </code></pre>
  
  <p>Expected out put :</p>
  
  <pre><code>         col_1    col_2    col_3    col_4    col_5
  file_1   42-55    34-58    94-51    43-27    14-95
  file_2   43-55    39-58    91-51    48-25    14-96
  </code></pre>