Selecting specific pieces of information from a text file and converting them to an array/list in python
<p>I have this project that I have to code in Python but it's extremely hard for a total beginner. Basically, I've never programmed in python and have only begun google learning it since yesterday, so I thought maybe you guys could help with it because I can't even begin to solve this.</p>

<p>I am given an initial textfile, let's call it input.txt, which has the following data in the following fashion:</p>

<pre><code>Thomas Hales
12 2345 
45 6780
63 3210
Peter Lebones
10 15430
11  1230
23 3450
John White
2 12130
11 32410
15 4520
</code></pre>

<p>There are names given and numbers under them. The numbers in the left column are simply identification numbers for the purposes of this problem. The numbers in the right column are money amounts that the people have invested in a bank let's say.</p>

<p>I'm supposed to take all of the data in the text file, manipulate it in ways, then make a new text file (all this is done by the script run by python) called output.txt
that for the above examples, contains this:</p>

<pre><code>Thomas Hales 45
Peter Lebones 10
John White 11
</code></pre>

<p>what I have this far (but it's not working. at all. plus it's a total mess, and I did it with the help of somebody, who also doesn't really know what he's doing):</p>

<pre><code>import sys
import subprocess
import re
import string


try:
    fread=open(sys.argv[1]).readlines()
except IOError:
    print "There is no file like that!"
    sys.exit()
except IndexError:
    print "There is no argumentum given"
alpha = string.ascii_letters
writeout=open("result.txt","w")
inputarray=fread.readlines()
for ... in inputarray: # not sure what goes in the "..." part
    array=inputarray.split('\n')
for i in range(len(array)-1):
    if array[i].isalpha():
    writeout.write(array[i]+" ")

fread.close()
writeout.close()
</code></pre>

<p>So basically, I am given a text file. I am then supposed to, for each person, select their highest investment, and associate the number in the left column with said highest investment. Then I'm supposed to make the script make an output.txt which contains the name of each person and the "Id number" of their highest investment.</p>
