Note that there are some explanatory texts on larger screens.

plurals
  1. POUpload and parse csv file with google app engine
    primarykey
    data
    text
    <p>I'm wondering if anyone with a better understanding of python and gae can help me with this. I am uploading a csv file from a form to the gae datastore. </p> <pre><code>class CSVImport(webapp.RequestHandler): def post(self): csv_file = self.request.get('csv_import') fileReader = csv.reader(csv_file) for row in fileReader: self.response.out.write(row) </code></pre> <p>I'm running into the same problem that someone else mentions here - <a href="http://groups.google.com/group/google-appengine/browse_thread/thread/bb2d0b1a80ca7ac2/861c8241308b9717" rel="noreferrer">http://groups.google.com/group/google-appengine/browse_thread/thread/bb2d0b1a80ca7ac2/861c8241308b9717</a></p> <p>That is, the csv.reader is iterating over each character and not the line. A google engineer left this explanation:</p> <blockquote> <p>The call self.request.get('csv') returns a String. When you iterate over a string, you iterate over the characters, not the lines. You can see the difference here: </p> </blockquote> <pre><code> class ProcessUpload(webapp.RequestHandler): def post(self): self.response.out.write(self.request.get('csv')) file = open(os.path.join(os.path.dirname(__file__), 'sample.csv')) self.response.out.write(file) # Iterating over a file fileReader = csv.reader(file) for row in fileReader: self.response.out.write(row) # Iterating over a string fileReader = csv.reader(self.request.get('csv')) for row in fileReader: self.response.out.write(row) </code></pre> <p>I really don't follow the explanation, and was unsuccessful implementing it. Can anyone provide a clearer explanation of this and a proposed fix?</p> <p>Thanks, August</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload