how to upload/download CSV file on Google App Engine

360 views
Skip to first unread message

Vincent Zhou

unread,
Aug 27, 2008, 11:05:14 PM8/27/08
to Google App Engine
Hi,
I'm new for Python and Google App Engine, So may I ask a very simple
or very stupid question ; (
I'm trying to upload a table from a csv file , store to google data
store and show this table on the web.
then in another page, I need compose the query result to a table and
also this table can be downloaded in csv format.
is anybody can share the code for the above scenarios? thanks in
advance.

Garrett Davis

unread,
Aug 28, 2008, 2:11:47 AM8/28/08
to Google App Engine
Google Search is your friend! If you have questions like this, you
can often find your own answers by Googling for "upload" and/or
"download".

Google provided a Bulk Upload process to upload data in csv format.
You can read about the Bulk Data Uploader here:
http://code.google.com/appengine/articles/bulkload.html

And I wrote a corresponding Bulk Download process to download data in
csv format. You can read about it, and download it, here:
http://code.google.com/p/gawsh/

You mentioned that you want to "compose the query result to a
table ...", and I hope you realize that if you only want to download a
subset of data based on some query, you have to write the code
yourself to handle the query and then modify the Bulk Downloader to
export the query results.
Message has been deleted

Vincent Zhou

unread,
Aug 28, 2008, 10:05:42 PM8/28/08
to Google App Engine
Thanks for your guys guidance. but it's not to use the buIk upload
procedure. I should explain more about my project.
the first is to edit a table more easier .
for example:
customer product price
CSTM_A PDT_A 1,000.00
CSTM_A PDT_B 2,000.00
CSTM_A PDT_C 1,000.00
CSTM_B PDT_A 1,050.00
CSTM_C PDT_C 950.00

So if I can download/upload this table, then it will more easy for me
to edit it through the excel.
but I don't know how to set up the download/upload procedure for it ;
(

Greg

unread,
Aug 28, 2008, 10:15:49 PM8/28/08
to Google App Engine
Just set up a page which formats the data as CSV - you'll need to
modify the headers so your browser knows it isn't HTML. Then provide a
form to upload your modifed data, and write it back to the datastore.

Vincent Zhou

unread,
Aug 29, 2008, 12:36:05 PM8/29/08
to Google App Engine
Thanks Greg.
Can anybody share a full code for this small task? I'm new to Python,
GAE and also web application ; (
anyway I can understand GAE's helloword tutorial.
I searched a lot online ( including CSV in GAE and also Python) and I
did not see a full code for similar task.
Thanks in advance.

Wooble

unread,
Aug 29, 2008, 2:49:27 PM8/29/08
to Google App Engine


On Aug 29, 12:36 pm, VV <zhou.vi...@gmail.com> wrote:
> Can anybody share a full code for this small task?

No.

How it gets imported is intimately connected to what your actual data
looks like. There's no one-size-fits-all solution to generic import
of any data into the datastore; your datastore models will need to be
written to accommodate your own data.

Vincent Zhou

unread,
Aug 29, 2008, 3:40:30 PM8/29/08
to Google App Engine
but my problem is there are many details I'm not familiar with.

for instance, based on source code of "helloworld",
first I can add a form to upload the file,

<form action="/process" enctype="multipart/form-data" method="post">
<div>file <input name="titles_file" type="file"></div>
<div> <input value="Submit" type="submit"></div>
<div> <input value="Clear the form" type="reset"></div>
</form>
( refer from http://groups.google.com/group/google-appengine/browse_thread/thread/fc87a92de8ae1a55)



I changed the Guesbook class as below. and it works to show the file
name as the content. But I don't know how to tell the code to read
inside this file.

class Processfile(webapp.RequestHandler):
def post(self):
greeting = Greeting()
thefile = self.request.params['titles_file']
file_name = thefile.filename
file_value = thefile.value

greeting.author = users.get_current_user()
greeting.content = file_name

greeting.put()
self.redirect('/')


That's why I want some source code and then I can modify the code for
implement my purpose. Thanks.

Vincent Zhou

unread,
Sep 2, 2008, 4:59:39 PM9/2/08
to Google App Engine
for instance, can somebody share the code to implement the table like
this?
http://finance.google.com/finance/historical?q=NASDAQ:GOOG

I just need upload the table and download the table. thanks a lot.
Reply all
Reply to author
Forward
0 new messages