Selected joining of lines
<p>I am very new with python and I need to solve the following (by hand or by python):
for a dataset, where each file consists of undefined-groups of lines of a varying number of numbers, followed by one line of text incl. dates and numbers (sorry if the sentence doesn't make sence):</p>

<pre><code>2,

4,

6,

1,

2,

02-sep-2016, blah blah, blah, 83838338

3,

0,

0,

03-Aug-2000, blah, 300033
</code></pre>

<p>I need the highest number above the line of text to be in front of the text and the rest to be deleted:</p>

<pre><code>6,02-sep-2016, blah blah, blah, 83838338

3,03-Aug-2000, blah, 300033
</code></pre>

<p>I know the <code>max()</code> function, but how do I specify as a general rule for all my files which numbers to include, and how can I selectively turn some numbers into an <code>int()</code> without including the sentence? 
I tried an <code>if</code> statement with <code>len(line)&lt;=3</code> and it is not working.</p>