from ftplib import FTP import os import gzip from pprint import pprint #Connect to FTP Site ftp = FTP("ftp.wwpdb.org") ftp.login() #Navigate to appropriate directory ftp.cwd("/pub/pdb/data/structures/divided/XML/") folders = ftp.nlst() #Iterate through each subdirectory containing all the protein structures for folder in folders: print ("Listing the " + folder + " directory.") #Iterate through each protein structure try: ftp.cwd(folder) except: continue files = ftp.mlsd() if files is None: ftp.cwd('../') continue else: pprint(files) for file in [value for value in files if value is not None]: ftp.retrbinary("RETR " + file, open(file, 'wb').write) unzip = gzip.decompress(file) pprint(unzip) ftp.quit()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question