I am trying to read CSV files from an ftp server in AppEngine and I can connect to an ftp server. But when he tried to restore the files, he returned an error. Here is my code for reading CSV files from the server:
import ftplib import cStringIO import csv session = ftplib.FTP('myftpserver.com') session.login('username','pwd') session.set_pasv(False) output = cStringIO.StringIO() session.retrbinary('RETR myfile.csv', output.write) csvfile = csv.reader(output.getvalue().splitlines(), delimiter=',') for i, row in enumerate(csvfile): print row
And here is the error trace I am getting:
Traceback (most recent call last): File "/home/vikas/apps/myproj/django/core/handlers/base.py", line 111, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/home/vikas/apps/myproj/admin/admin_actions.py", line 3528, in get_ftp_file session.retrbinary('RETR myfile.csv', output.write) File "/usr/lib/python2.7/ftplib.py", line 414, in retrbinary conn = self.transfercmd(cmd, rest) File "/usr/lib/python2.7/ftplib.py", line 376, in transfercmd return self.ntransfercmd(cmd, rest)[0] File "/usr/lib/python2.7/ftplib.py", line 354, in ntransfercmd sock = self.makeport() File "/usr/lib/python2.7/ftplib.py", line 283, in makeport for res in socket.getaddrinfo(None, 0, self.af, socket.SOCK_STREAM, 0, socket.AI_PASSIVE): File "/home/vikas/gcloud/google-cloud-sdk/platform/google_appengine/google/appengine/api/remote_socket/_remote_socket.py", line 318, in getaddrinfo raise gaierror(EAI_NONAME, 'nodename nor servname provided, or not known') gaierror: [Errno 8] nodename nor servname provided, or not known
I have no idea what I did wrong, none of the commands, such as dir() nlst() , etc., work, and the indicated error occurred as soon as I added them.
python google-app-engine csv ftp
vikas.sh
source share