We have answer of your question!

100% solved queries, no empty question

Question: Unzip csv file from Zip on ftp server


0

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

Question author Databoe | Source

Answer


1


Fixed using:

ftp.retrlines('RETR %s' % fpath ,lambda s, w=outzip.write: w(s+"\n"))
Answer author Databoe

Tickanswer.com is providing the only single recommended solution of the question Unzip csv file from Zip on ftp server under the categories i.e python-2.7 , ftp , zip , . Our team of experts filter the best solution for you.

Related Search Queries:

how to extract zip file on ftp server , unzip file on server , create zip file on ftp server ,


You may also add your answer

Thanks for contributing an answer to Tick Answer!