Skip to content

Instantly share code, notes, and snippets.

@mhweber
Last active September 20, 2016 16:00
Show Gist options
  • Select an option

  • Save mhweber/5619e1c862bb11198a24cc1a0bfcb54c to your computer and use it in GitHub Desktop.

Select an option

Save mhweber/5619e1c862bb11198a24cc1a0bfcb54c to your computer and use it in GitHub Desktop.
Example of ftp download for StreamCat data
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 20 08:20:02 2016
@author: mweber
"""
import os
from ftplib import FTP
outdir = 'c:/users/mweber/temp/'
ftp = FTP('newftp.epa.gov')
ftp.login()
ftp.cwd("/EPADataCommons/ORD/NHDPlusLandscapeAttributes/StreamCat/HydroRegions/") #just need to set this upper directory for each state
filelist=ftp.nlst()
for filename in filelist:
if filename.count("STATSGO_Set2_Region07.csv"):
download_file = filename
print "Downloading ", download_file
outfile=open(outdir + download_file,'wb')
ftp.retrbinary('RETR ' + download_file, outfile.write, 1024)
ftp.quit()
outfile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment