Conversion of Multiple Strings To ASCII
<p>This seems fairly trivial but I can't seem to work it out</p>

<p>I have a text file with the contents:</p>

<blockquote>
  <p>B>F</p>
</blockquote>

<p>I am reading this with the code below, stripping the '>' and trying to convert the strings into their corresponding ASCII value, minus 65 to give me a value that will correspond to another list index</p>

<pre><code>def readRoute():
    routeFile = open('route.txt', 'r')
    for line in routeFile.readlines():
        route = line.strip('\n' '\r')
        route = line.split('&gt;')
        #startNode, endNode = route
        startNode = ord(route[0])-65
        endNode = ord(route[1])-65

    # Debug  (this comment was for my use to explain below the print values)
    print 'Route Entered:'
    print line
    print startNode, ',', endNode, '\n'
    return[startNode, endNode]
</code></pre>

<p>However I am having slight trouble doing the conversion nicely, because the text file only contains one line at the moment but ideally I need it to be able to support more than one line and run an amount of code for each line.</p>

<p>For example it could contain:</p>

<pre><code>B&gt;F
A&gt;D 
C&gt;F 
E&gt;D
</code></pre>

<p>So I would want to run the same code outside this function 4 times with the different inputs</p>

<p>Anyone able to give me a hand</p>

<h2>Edit:</h2>

<p>Not sure I made my issue that clear, sorry</p>

<p>What I need it do it parse the text file (possibly containing one line or multiple lines like above. I am able to do it for one line with the lines</p>

<pre><code>startNode = ord(route[0])-65
endNode = ord(route[1])-65
</code></pre>

<p>But I get errors when trying to do more than one line because the <code>ord()</code> is expecting different inputs
If I have (below) in the route.txt</p>

<pre><code>B&gt;F
A&gt;D
</code></pre>

<p>This is the error it gives me: </p>

<pre><code>line 43, in readRoute  endNode = ord(route[1])-65
TypeError: ord() expected a character, but string of length 2 found
</code></pre>

<p>My code above should read the route.txt file and see that B>F is the first route, strip the '>' - convert the B &amp; F to ASCII, so 66 &amp; 70 respectively then minus 65 from both to give 1 &amp; 5 (in this example)
The 1 &amp; 5 are corresponding indexes for another "array" (list of lists) to do computations and other things on
Once the other code has completed it can then go to the next line in route.txt which could be A>D and perform the above again</p>
