I've got a quite simple task I have to automate to have an analysis. I've discovered similar questions about this forum although not put on an ordinary text file, and like me a python newbie I don't know how you can convert these solutions straight to me. So I'd appreciate any help.

I've got a number of files within this format:

11 5012 1000 10036040.000000 1.089555 4.529811 0.150000
11 5013 1000 10038040.000000 1.089783 4.340549 0.150000
11 5014 1000 10039040.000000 1.090000 4.733367 0.150000
11 5015 1000 10044040.000000 1.090217 4.601943 0.150000
11 5016 1000 10044040.000000 1.090435 5.048237 0.150000
11 5017 1000 10046040.000000 1.090652 1.280908 0.050000

each file is known as "data1-1", "data1-2", "data1-3" etc The information is separated by single spaces and there's no header

I'd like a script to enter each file, discover the row using the max value in column 5 (eg value 5.048237 above) and also to print that row right into a new output file. Ultimately I want one output file that consists of the rows using the max value in column 5 from each one of the input files. Therefore if there have been 5 input files the output file might have 5 rows.

I really hope this really is obvious, any assistance is really appreciated!

import glob, operator

fpout = open("result.dat","w")

for path in glob.glob("data?-?"):
    with open(path, "r") as fp:
        fields = [ line.split(" ") for line in fp ]
        maxline = " ".join(max(fields, key = lambda row: float(row[5]))
        print >> fpout, maxline