title: Python read numbers in text file to list to calculate mean
body: <p>I have a file with a lot of numbers and I want to try to read it in python into a list of a list. Then calculate its mean or sum or whatever.</p>
  
  <p>Here is my text file:</p>
  
  <pre><code>   1,2,5349,2398,19,3450
     10,95,201,5943,234,2319482,12
  </code></pre>
  
  <p>then here is my code:</p>
  
  <pre><code>def ReadList(fileName):
      with open(fileName, 'r') as numbers:
          datalist = [] 
          for line in numbers:
              datalist.append(line.strip().split(' '))
      return datalist
  </code></pre>
  
  <p>but my results turn up as datalist = ['1,2,5349....3450'],['10,95...,12'] they have the apostraphe at the beinning and the end, and I can't calculate the mean with it. I have tried to use:
                       <code>datalist.appent(int(line.strip().split(' ')))</code>already and it doesn't make the data into numbers but adds some other errors.</p>
  
  <p>EDIT: The data seem okay now that I changed it to <code>datalist.append([int(x) for x in line.strip().split(',')])</code>. </p>
  
  <p>But I can't calculate the mean when my method is</p>
  
  <pre><code>numbers = ReadList('data.txt')
  
  total = 0.0
  for num in numbers:
       total = total + num
  return total/len(nums)
  </code></pre>
  
  <p>the same errors still appear:<code>"TypeError: unsupported operand type(s) for +: 'float' and 'list'"</code></p>
  
  <p>My goal is to have it as a few separate list of a list and calculate each separate list's means and then display it in a column for example:</p>
  
  <pre><code>List# Mean
  1     (Mean value of the first list( 1,2,5349,2398,19,3450))
  2     (Mean value of the second list(10,95,201,5943,234,2319482,12))
  </code></pre>