title: Python: ValueError: could not convert string to float: '4623634 0'
body: <p>Here is my code: </p>
  
  <pre><code>import csv
  with open ("Filename1.txt") as f:
     dict1 = {}
     r = csv.reader(f,delimiter="\t")
     for row in r:
  
         a, b, v = row
         dict1.setdefault((a,b),[]).append(v)
  
     #for key in dict1:
        #print(key[0])
        #print(key[1])
        #print(d[key][0]])
  
  with open ("Filename2.txt") as f:
     dict2 = {}
     r = csv.reader(f,delimiter="\t")
     for row in r:
  
         a, b, v = row
         dict2.setdefault((a,b),[]).append(v)
  
     #for key in dict2:
         #print(key[0])
  
      count = 0
      for key1 in dict1:
         for key2 in dict2:
            if (key1[0] == key2[0]) and abs(float(key1[1])) - (float(key2[1])) &lt; 10000:
             count += 1   
  </code></pre>
  
  <p>Previously I was getting this error: </p>
  
  <pre><code>Traceback (most recent call last):
  File "/Users/macbookpro/Desktop/MainDict.py", line 28, in &lt;module&gt;
  if key1[0] == key2[0] and abs(key1[1] - key2[1]) &lt; 10000:
  TypeError: unsupported operand type(s) for -: 'str' and 'str' 
  </code></pre>
  
  <p>So of course I tried turning those strings into integers. However I then got this error:</p>
  
  <pre><code> Traceback (most recent call last):
   File "/Users/macbookpro/Desktop/MainDict.py", line 28, in &lt;module&gt;
   if (key1[0] == key2[0]) and abs((int(key1[1])) - (int(key2[1]))) &lt; 10000:
   ValueError: invalid literal for int() with base 10: '1002569 1'
  </code></pre>
  
  <p>Then I tried using float and now I get this error, which is where I am stuck now:</p>
  
  <pre><code> Traceback (most recent call last):
   File "/Users/macbookpro/Desktop/MainDict.py", line 28, in &lt;module&gt;
   if (key1[0] == key2[0]) and abs(float(key1[1])) - (float(key2[1])) &lt; 10000:
   ValueError: could not convert string to float: '2486997 2'
  </code></pre>
  
  <p>Here are examples of what my input files consist of:</p>
  
  <p>Filename1</p>
  
  <pre><code>1   11383002    8 1.16E-05
  1   159962368   1.17E-05
  2   133623587   1.26E-05
  2   1002569 1   3.30E-06
  3   168940139   1.40E-05
  3   49736942    1.43E-05
  </code></pre>
  
  <p>Filename2</p>
  
  <pre><code>10  11383002    8 1.16E-05
  5   159962368   1.17E-05
  7   133623587   1.26E-05
  9   1002569 1   3.30E-06
  8   168940139   1.40E-05
  1   49736942    1.43E-05
  </code></pre>
  
  <p>Now my question is, why am I getting this error. Is there something in the code specifically? Or is there something wrong with my text files. What suggestions do you having on fixing this problem and how can I alter my code (if that's the case) to do so?</p>