read data in specific column and row of a text file
<p>I Have a text file which contain 3 columns and 20000 rows.
I like to know what should I do to get the specific data (for example) in row 1000 and column 2?
My first column is formatted like AAAA and my second column is a number like 1234.
I tried this solution but I got an error based on my first column being letters
I would like to define a variable which contains my data at the end:</p>

<pre><code>with open ('my_file') as f:
    for x , line in eumerate(f):
         if x = 1000:
             numfloat = map(float , line.split())
             print numfloat[1]
</code></pre>

<p>You are trying to use <code>float()</code> on something that contains letters.  this happens when you call:</p>

<pre><code>numfloat = map(float , line.split()) 
</code></pre>

<p>You need to tell us the exact output that you are looking for but here is one possible solution</p>

<pre><code>num_float = map(float, line.split()[1])

or better yet

num_float = float(line.split()[1])
</code></pre>

<p>This will only get you the middle column, I'm not certain if you need the entire row or not.</p>

<p>Additionally, as noted below, you need to change <code>=</code> to <code>==</code> in your if statement.  <code>=</code> is for assigment, <code>==</code> is for comparison.</p>

python text row line