I have text in a file that looks like this:
text1 5,000 6,000
text2 2,000 3,000
text3
5,000 3,000
text4 1,000 2000
text5
7,000 1,000
text6 2,000 1,000
Is there any way to clean this up in Python so that if there are missing numbers after a text line, the numbers on the subsequent line can be placed on the line above:
text1 5,000 6,000
text2 2,000 3,000
text3 5,000 3,000
text4 1,000 2000
text5 7,000 1,000
text6 2,000 1,000
Thanks!
Assuming that logical lines “continue” on lines which start with whitespace (and contain arbitrary amount of records), you can use this: