1
import json
import gzip
import linecache

cnt = 0
jsonfile = 'refsnp_blobs.json.gz'

........
....

fin = gzip.open(jsonfile,'r')  
fin.seek(100, 0)                  #go to random position
print(fin.readline())
exit()

refsnp_blobs.json.gz is available on external FTP server, I don't want to download since its more the 50 gb. If there is any way to do this ?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
dkmaven
  • 77
  • 1
  • 1
  • 6

1 Answers1

0

You cannot access contents of an archive file stored on a remote FTP server without actually downloading the file.

Of course, you can extract the contents while downloading on-the-fly, without actually storing the archive file locally (as suggested by @Cheney in a comment). This way, you spare a local storage, but you will still waste a bandwidth.


If you have a shell access to the server, you can extract the file remotely and access only the part of the extracted contents you are after.


For a similar question, see Download zip file via FTP and extract files in memory in Python.

Community
  • 1
  • 1
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992