title: Python/jython join two lists in list of lists with condition
body: <p>I have a text file that was used for fortran and the line limit on the text file is limited to 80 characters. I am attempting to parse it in python.</p>
  
  <p>There are characteristic tables for different projects and within those tables there are tables of tables.  Different sites may have all or none of the data shown below.</p>
  
  <pre><code>1PROGRAM                                          MYPRJ PROJECT CHARACTERISTIC DATA                           PROJECT
      11/22/00                                               MASTER FILE                                  NO     NAME       REV
                                                                                                           1   PROJ          
  
  
   DATA1                   7000.0  uni
   DATA2                  -5000.0  uni
   DATA3                          12000.0  uni
   DATA4                    3000.  uni
  
  
  
   TBL1 TITLE            
     VAL1 UNI            0.0    10000.0    30000.0    60000.0   100000.0   300000.0
     VAL2 UNI             1858.0     1863.4     1870.3     1876.0     1882.0     1900.0
  
  
   TBL2 TITLE         
     VAL1 UNI         6542.0     1156.7     3697.1     4569.3     9564.9     5698.0     9874.7     3654.7     3698.8     2135.0
                          7894.0     5568.0     7845.3     3657.7
     VAL2 UNI            0.0    18300.0    22500.0    99900.0    36900.0    69800.0    58700.0    63520.0    69870.0    55260.0
                         61100.0   127900.0   166600.0   236900.0
  
  
   TBL3 TITLE
     VAL1 UNI            -4876.9    -5642.3    -1225.7        9.0      375.4      322.0     8860.8     1568.1     4567.0     6953.0
                          6578.1     1236.7     3970.0     5632.3     3265.1     3698.1     1236.2     1236.4     7000.0
     VAL2 UNI             3265.1     1236.7     5632.3     2394.1     2405.0     1876.0     7845.3     2420.0     5568.0     2548.0
                          5632.3     3265.1     2694.1     5568.0     2455.0     5632.3     1863.4     2670.0     2565.0
  </code></pre>
  
  <p>I have been reading this in by </p>
  
  <pre><code>f = open("file.asc")  
  f = [line.replace('\n','').strip() for line in f]
  </code></pre>
  
  <p>The difficulty I have been having is with the different sized tables, such as TBL1, and TBL2.  TBL1 is small and all values are contained on a single line.  TBL2 and TBL3 the values are longer than the 80 character limit and extend to the next line.  Therefore in my list of lists TBL2 VAL1 is broken up into two lists.</p>
  
  <pre><code>TBL1 = [['TBL1 TITLE'], ['VAL1 UNI', '0.0', '10000.0', '30000.0', '60000.0', '100000.0', '300000.0'],['VAL2 UNI','1858.0', '1863.4', '1870.3', '1876.0', '1882.0', '1900.0']]
  TBL2 = [[['TBL2 TITLE'],['VAL1 UNI', '6542.0', '1156.7','3697.1', '4569.3', '9564.9', '5698.0', '9874.7', '3654.7', '3698.8', '2135.0'], ['7894.0', '5568.0', '7845.3', '3657.7'], ['VAL2 UNI', '0.0', '18300.0', '22500.0', '99900.0', '36900.0', '69800.0', '58700.0', '63520.0', '69870.0', '55260.0'],['61100.0', '127900.0', '166600.0', '236900.0']]]
  </code></pre>
  
  <p>I have left out TBL3 for brevity</p>
  
  <p>What I want is</p>
  
  <pre><code>TBL1 = [['TBL1 TITLE'], ['VAL1 UNI', '0.0', '10000.0', '30000.0', '60000.0', '100000.0', '300000.0'],['VAL2 UNI','1858.0', '1863.4', '1870.3', '1876.0', '1882.0', '1900.0']]
  TBL2 = [[['TBL2 TITLE'],['VAL1 UNI', '6542.0', '1156.7','3697.1', '4569.3', '9564.9', '5698.0', '9874.7', '3654.7', '3698.8', '2135.0','7894.0', '5568.0', '7845.3', '3657.7'], ['VAL2 UNI', '0.0', '18300.0', '22500.0', '99900.0', '36900.0', '69800.0', '58700.0', '63520.0', '69870.0', '55260.0','61100.0', '127900.0', '166600.0', '236900.0']]]
  </code></pre>