I'm new to python. I want to access baseURL and eventually get a list of files in one of the sub-directories so I can download/unzip this file. The specific file extension can change so I'm hoping to find a match to the file by just the date (yyyymmdd).
baseURL = 'ftp://prism.nacse.org'
Thanks in advance for your guidance!
My code so far is:
variables = ['ppt', 'tmax', 'tmin']
nvars = len(variables)
baseURL = 'ftp://prism.nacse.org/daily/'
stDateNum = date.toordinal(date(1981,1,1)) # Year, Month, Day
edDateNum = date.toordinal(date(2017,4,22))
dates = list(range(stDateNum,edDateNum+1))
ndates = len(dates)
for v in range(0,nvars):
for d in range(0,ndates):
tmpdate = date.fromordinal(dates[d]).strftime('%Y%m%d') #yyyymmdd
tmpYR = date.fromordinal(dates[d]).strftime('%Y') #yyyy
totalpath = baseURL + variables[v] + '/' + tmpYR + '/*_' + tmpdate + '_bil.zip'
You could use Python ftplib, https://docs.python.org/3/library/ftplib.html, as a ftp client. I don't think wildcard downloads are support, so you'd have to do something along the lines of...