appengine:解析上传文件中的csv数据 [英] appengine: parse a csv data in uploaded file

查看:138
本文介绍了appengine:解析上传文件中的csv数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何模块或包可以帮助解析appengine中已上传的csv文件中的csv内容。试图在python中使用csv包。但它只能解析文件系统中的文件,但不能数据..
http:// docs.python.org/library/csv.html

Are there any modules or packages which help parsing csv content from a uploaded csv file in appengine. tried using the csv package in python. but it could parse only files in file system but could not data.. http://docs.python.org/library/csv.html

推荐答案


但它可以仅解析文件
系统中的文件,但不能数据

but it could parse only files in file system but could not data

否, csv.reader 接受任何支持逐行迭代的对象。假设cgi.FieldStorage支持它,并且假设你发布了一个名为file的文件,你应该能够这样做:

No, csv.reader accepts any object that supports line-by-line iteration. Assuming cgi.FieldStorage supports it, and assuming you've posted a file named "file", you should be able to do this:

import csv
for row in csv.reader(self.request.POST['file']):
  # process row

这篇关于appengine:解析上传文件中的csv数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆