title: Python SFTP issues
body: <p>I wrote a program that will look at a text file and export the errors within the file to another txt file. Then the program goes to a linux host via sftp and transfer the file to a specific location.  However, I'm getting an error when running this program: </p>
  
  <pre><code>import os
  import sys
  import csv
  import pysftp 
  
  with open('c:/Python27/log_07032014_1512.txt','r') as inf,    
      open('C:/Python27/Errors.txt','w')as outf:
      reader = csv.reader(inf)
      writer = csv.writer(outf)
      for line in inf:
          if 'Error' in line:
              print line
  
  def sftpExample():
      try:
          s = sftp.Connection('***.***.***.***', username = '******', password = '****')
          remotepath ='/home/*****/BOA.txt'
          localpath = 'C:/Python27/Errors.txt'
          s.put(localpath,remotepath)
  
          s.close()
      except Exception, e:
          print str(e)
  
  sftpExample()
  </code></pre>
  
  <p>I get the following error when it reads and then tries to transfer the files: </p>
  
  <p>global name 'sftp' is not defined. </p>
  
  <p>Can anyone help on this? </p>