I need to upload and process a CSV file from a form in a Google App Engine application based on Webapp2 (Python) I understand I could use blobstore to temporary store the file but I am curious to know if there is a way to process the file without having to store it at all.
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
If you need to upload a file via webapp2 with an HTML form, the first thing you need to do is change HTML form
enctype
attribute tomultipart/form-data
, so the code snippet seems like:In python code, you can read the file directly via
request.POST
, here's a sample code snippet:The content of uploaded files is in
self.request.POST
in your handler, so you can get that content (assuming e.g the field for the uploaded file is named'foo'
) with e.gSo now you have the content as a string -- process it as you wish. This does of course assume the thing will fit in memory (no multi-megabyte uploads!-)...