title: Python - Best way to append a sequence of numbers to a text file?
body: <p>Let's say that I have textfile of a series of numbers that looks like this:</p>
  
  <pre><code>18,18,19,19,16,20,19,20,18,20,21
  </code></pre>
  
  <p>That's only a preview of hundreds of numbers separated by commas. I want to be able to manipulate the data in python in a [list]. So I have a variable src that I want to append the integer values to from the text file.</p>
  
  <p>Like so:</p>
  
  <pre><code>text_file = open("sequence.txt","r")
  src = []
  
  for entry in text_file.read():
      if(entry != ','):
          src.append(int(entry))
  </code></pre>
  
  <p>Obviously this get's rid of the ',' between each entry in my textfile however values like 20 in the textfile will be appended to the list as two separate entries [2,0].</p>
  
  <p>What's the best way to append these values ? 
  Thanks !</p>