Python3: Extract data from .txt files and take those data in rows and column : I have a set of datas from a .txt file in this format:

    30     1
         2477.25     0.00    1                   M
    40     2   11
            0.17100     0.08600     0.11500     0.10800     0.05600     0.07500 9.60000 -1009.00000 -1009.00000 -1009.00000
            2.70000
    36     1    1
       a.a.Sbargang
    30     1
         2477.45     0.00    2                   M
    40     2   11
          0.52100     0.27400     0.35900 -1009.00000 -1009.00000 -1009.00000    14.30000 -1009.00000 -1009.00000 -1009.00000
          2.66000
    36     1    1
       a.a M-gr.


The format is quite messy, and I want to make it in rows and columns so my output will be like this:

    30 1 2477.25 0.00 1 M 40 2 11 0.17100 0.08600 0.11500 0.10800 0.05600  0.07500 9.60000 -1009.00000 -1009.00000 -1009.00000 2.70000 36 1 1 a.a.Sbargang
    30 1 2477.45 0.00 2 M 40 2 11 0.52100 0.27400 0.35900 -1009.0 -1009.0 -1009.00 14.3000 -1009.00000 -1009.00000 -1009.00000 2.66000 36 1 1 a.a M-gr.

I am quite new to python and not sure how to write python3 to do this task? Thanks in advance


