Debugging- Spot Error In Script For Finding Max Value
Hello everyone,
When I try and run the following code
import glob, operator
fpout = open("result.dat","w")
for path in glob.glob("*.txt"):
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
I get the error:
File "findmaxvalue.py", line 9
print >> fpout, maxline
^
SyntaxError: invalid syntax
Does anyone with experience with python know how to fix it?
If details on the function help: I am reading into a group of files in a directory and asking what is the highest integer value in column 5. The row containing this value is then to be printed to a new output file, containing the row with the highest value from each input file. It's to help with some population genetic analyses.
All help greatly appreciated, Thanks!
Rubal
• 202 views
•
link
0 answers
No answers yet.
Log in to answer this question.
Problem solved (missing bracket :S)