I want to log into a ftp server (not a public url) and download a csv file which is located in a zip file and then save this to a particular directory:
#log in OK
# this is the zip file I want to download
fpath = strDate + ".zip"
#set where to save file
ExtDir = "A:\\LOCAL\\DIREC\\TORY\\"""
ExtDir = ExtDir + strdate + "\\"
ExtFile = ExtDir + "Download.zip"
#download files
#use zipfile.ZipFile as alternative method to open(ExtFile, 'w')
with zipfile.ZipFile(ExtFile,'w') as outzip:
ftp.retrbinary('RETR %s' % fpath , outzip.write)
outzip.close
I get this error
File "C:\Program Files (x86)\Python 2.7\lib\ftplib.py", line 419, in retrbinary callback(data) File "C:\Program Files (x86)\Python 2.7\lib\zipfile.py", line 1123, in write st = os.stat(filename) TypeError: stat() argument 1 must be encoded string without null bytes, not str