开发者

appengine: parse a csv data in uploaded file

Are there any modules or package开发者_如何学Gos 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

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


There is a blobstore input format for the App Engine Mapper: http://code.google.com/p/appengine-mapreduce/

It will read each line from the CSV and send it to your mapper for reading/import. Be careful though because it breaks if there are escaped new lines in the CSV.

Here is an example with the Java implementation: http://ikaisays.com/2010/08/11/using-the-app-engine-mapper-for-bulk-data-import/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜