I need to parse some text and integers from a file
<p>I'm having trouble with a problem I'm trying to do. My goal is to import a file that contains football teams names, and then the number of wins and losses, and then if a team's average is greater than .500, than I have to write that teams name, and average to a new file. And then I have to write the teams under .500 to a seperate file. so far I have my code so that it reads eachline of the file, but I can't figure out how to analyize each line of code. I'm really just looking for any advice I could get at this point, and it would be greatly appreciated.</p>

<pre><code>scores = open("fbscores.txt",'r')
eachline = scores.readline()
while eachline != "":
    print(eachline)
    eachline = scores.readline()
scores.close()
</code></pre>

<p>Given an example line of the file like this:</p>

<pre><code>Cowboys 4 1
</code></pre>

<p>Then some code might look like this:</p>

<pre><code>line = scores.readline().split()
teamName = line[0]
wins = int(line[1])
losses = int(line[2])

if wins &gt; losses:
    print(teamName + "'s record is over .500!")
    goodTeams.write(line)
    goodTeams.write() #make a new line
else:
    print(teamName + "'s record is &lt;= .500.")
    badTeams.write(line)
    badTeams.write()
</code></pre>

<p>To find the average of a team with x wins and y losses, do:</p>

<pre><code>"%0.3f" % (x/(x+y))
</code></pre>

<p>Gives:</p>

<pre><code>&gt;&gt;&gt; "%0.3f" % (4/(4+1))
'0.800'
&gt;&gt;&gt; 
</code></pre>

python