-1

I connected to a sftp and got a list of files successfully:

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy( paramiko.AutoAddPolicy() )

ssh.connect(Hostname, username=Username, password=Password)

ftp = ssh.open_sftp()
files = ftp.listdir()

dir_oi = "blah"
foi = ftp.listdir(dir_oi)
foi = [i for i in foi if '.csv' in i]
foi = [i for i in foi if not '.test.' in i]
len(foi)

and I get a list of 500+ csvs. I would like to read them to process, but am hitting a block.

remote_file = ( dir_oi +"/" + foi[0])

I tried pd.read_csv(remote_file) and other parimiko suggestions from SO to no avail.

Any suggestions?

martineau
  • 119,623
  • 25
  • 170
  • 301
frank
  • 3,036
  • 7
  • 33
  • 65

1 Answers1

-1

I found this method worked

with ftp.open(remote_file) as f:
    df = pd.read_csv(f, sep = '\t', header = None)
frank
  • 3,036
  • 7
  • 33
  • 65
  • 1
    Well, that's what my answer to [Reading .csv file to memory from SFTP server using Python Paramiko](https://stackoverflow.com/q/56652280/850848) shows. If that works, please consider upvoting the posts. In any case, please do not post duplicate answers. – Martin Prikryl May 13 '22 at 14:21