title: Read .txt file and analyze
body: <p>I'm working Huffman coding of any .txt file, so first I need to analyse this text file. I need to read it, then analyse.
  I need "exit" like table:</p>
  
  <hr>
  
  <p>letter | frequency(how many times same latter repeated)  |  Huffman code(this will come later)</p>
  
  <hr>
  
  <p>I started with:</p>
  
  <pre><code> f = open('test.txt', 'r')    #open test.tx
   for lines in f:
       print lines          #to ensure if all work...
  </code></pre>
  
  <hr>
  
  <p>How can I order reading characters from file in alphabetic order:</p>
  
  <pre><code>with open("test.txt") as f_in:
      for line in f_in:
          for char in line:
              frequencies[char] += 1
  </code></pre>
  
  <p>???Many thanks</p>
  
  <hr>
  
  <pre><code>Well I tried like this:
  frequencies = collections.defaultdict(int)
  with open("test.txt") as f_in:
      for line in f_in:
          for char in line:
              frequencies[char] += 1
  
  
   frequencies = [(count, char) for char, count in frequencies.iteritems()]
   frequencies.sort(key=operator.itemgetter(1))
  </code></pre>
  
  <p>But compiler return me an "error"
      enter code here</p>
  
  <p>I need this alphabetic order <strong>in for loop</strong>, not at end at  frequencies...</p>