1

I am trying to access an FTP (NCBI genomes bank) and loop through the files and read them.

I got the part where I can read a local file and I can connect to a FTP but I can't find what I should do to read files directly from the FTP (if possible without having to download it).

    ftp         = Net::FTP.new("ftp.ncbi.nlm.nih.gov")
    ftp.passive = true
    ftp.login

I found this but it's in Python and I am having trouble finding equivalent methods and libraries.

Thanks in advance for your help

Community
  • 1
  • 1

1 Answers1

0

What your looking for is Net::FTP

ftp = Net::FTP.new("ftp.ncbi.nlm.nih.gov")
ftp.passive = true
ftp.login
files = ftp.chdir('/foo')
ftp.gettextfile('test.txt') do |txt|

  # do something with text
end
ftp.close
max
  • 96,212
  • 14
  • 104
  • 165
  • Thank you very much for your help ! It works exactly the way I want ! In case someone with the same problem is wondering gettextfile return each line of the document as txt (in that case) – Nicolas Sounac Sep 23 '14 at 13:57