I’m uploading a csv/tsv file from a form in GAE, and I try to parse the file with python csv module.
Like describe here, uploaded files in GAE are strings.
So I treat my uploaded string a file-like object :
file = self.request.get('catalog')
catalog = csv.reader(StringIO.StringIO(file),dialect=csv.excel_tab)
But new lines in my files are not necessarily ‘\n’ (thanks to excel..), and it generated an error :
Error: new-line character seen in unquoted field – do you need to open the file in universal-newline mode?
Does anyone know how to use StringIO.StringIO to treat strings like files open in universal-newline?
How about:
or as pointed out in the comments,
csv.reader()supports input from a list, so:or if in the future
request.getsupports read modes: