python - Going back to the start of a sftp remote-file -


I am using the permissions to open a remote file, via sftp. The remote file has a list of phrases and I want to see again through each row of the file to see if a given phrase matches the remote file.

Code used to get a remote file:

  self.ssh = paramiko.SSHClient () self.ssh.set_missing_host_key_policy (paramiko.AutoAddPolicy ()) Self.ssh.connect (host, user name = username, password = password) self.sftp_client = self.ssh .open_sftp () self.remote_file = self.sftp_client.open (remote_file_path, mode = 'rb') def checksbnet ( Self, Phrase): found in the line for self.remote_file = 0: if the phrase in the line: found = 1 print "it was found that" brake returns  

this first phrase match Tax Area will work, however, is to be matched to the next phrase, will file before the last one, then he will not. I've debug it for a loop to resume, from where it was broken in the last match. I would understand that it will resume at the top of the file.

Is this behavior changing? Or there is a better way to do this, it has about 9,000,000 phrases in the file, and changes everyday, so it is not possible to have a local version.

thanks

to return to the beginning of the file loop Find a before for (0) call:

  def checksbenet (self, phrase): found = 0 self.remote_file.seek ( 0) For the line in self.remote_file: If the phrase in the line: found = 1 print "IT IT" returned the brake  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -