Error when converting string to float
<p>I am having troubles writing a python script. Specifically, I have a string of numbers and want to replace the word ''zero'' with the integer 0. I then want to cover this string into float values. I used data.replace, and as such had to put "" around the 0 - if not there is an error as it expects a character buffer object. Am I right in saying that I can strip the "" from the 0 before converting to a float?</p>

<pre><code>&gt;  for data in inFile: 
&gt;  data = data.replace ("zero", "0")

&gt;  data = map(float,data.strip('"'))                                                            
</code></pre>

<blockquote>
  <p>ValueError: could not convert string to float: s</p>
</blockquote>

<p>It is part of a larger script, which takes in a list of values. I want to subtract the last 100 values of this list for a given line from the first 100. </p>

<pre><code>inFile = gzip.open('path','rb')

inpNorm = 0.5
samNorm = 1

inFile.next()
for line in inFile:
        cols = line.strip().split('\t')
        data = cols[6:]
        for data in inFile:
                data = data.replace("zero",0)
        data = map(float,data.strip('"'))

        inputVals = [x * inpNorm for x in data[:100]]
        h3k27Vals = [x * samNorm for x in data[100:]]

        normVals = [h327Vals[i] - inputVals[i] for i in len(inputVals)]

        print '\t'.join(cols[:6]) + '\t'.join(map(str,normVals))

inFile.close()
</code></pre>

<p>My input file looks like the following: </p>

<pre><code>C8098283        1       8268    asx1.1_ox1.0.loc.00001  .       +  zero    zero    zero    11.701  12.801   13.91
</code></pre>

<p>Many thanks </p>

<p>P.S. Really sorry if this is not explicit enough. Im very new to programming and stack overflow. </p>