I'm trying to read a CSV file from an FTP server and parse it on app engine. I can access the file and read it to
StringIO but when I try to loop over the files lines it just loops over every character instead of lines. Not sure what I'm doing wrong here:
ftp = FTP('ftp.mydomain.com', 'username', 'pwd') ftp.set_pasv(True) r = StringIO() ftp.retrbinary('RETR test.csv', r.write) csvfile = csv.reader(r.getvalue(), delimiter=',') for line in csvfile: print line
this ends up in something like this:
['O'] ['R'] ['D'] ['E'] ['R'] ['N'] ['O'] ['', ''] ['O'] ['R'] ['D'] ['E'] ['R'] ['D'] ['A'] ['T'] ['E'] ['', ''] ['I'] ['N'] ['V'] ['O'] ['I'] ['C'] ['E'] ['N'] ['O'] ['', ''] ...
What is the correct way to do this and correctly parse the file from FTP so the
csv module can read it correctly?