Reading from a static text file

23 views
Skip to first unread message

prasy

unread,
Mar 16, 2009, 12:17:14 AM3/16/09
to Google App Engine
Hi..

Im abt to create a spell check application.. I have a text file called
"wordlist.txt' containing english words. I will be getting a wrd from
user and checks its spelling wit de help of the text file.

I simply need to read de file.. Is it possible for me to run tis app
in appengine.. Bcz i heard tat its not possible to read de contents of
a static file in app engine. Moreover de file is around 2 MB so i cant
simply make it as list or dict type and use..

Regards,
Prasy..

djidjadji

unread,
Mar 16, 2009, 3:31:31 AM3/16/09
to google-a...@googlegroups.com
Why don't you put the file in the datastore.

You can put it on a word basis, one object for every word, db.StringProperty.
Use the datastore index to find the word. Use bulk_upload to fill the datastore.

Or split it up in parts, each part starting with a different
character. Put it in db.TextProperty.

2009/3/16 prasy <prasan...@gmail.com>:

Nash-t

unread,
Mar 16, 2009, 2:14:50 PM3/16/09
to Google App Engine
if all you really have to do is read the file you could just put it in
a .py file and import it.
Store it as a dictionary or an array or an object. Whatever works.

On Mar 16, 12:31 am, djidjadji <djidja...@gmail.com> wrote:
> Why don't you put the file in the datastore.
>
> You can put it on a word basis, one object for every word, db.StringProperty.
> Use the datastore index to find the word. Use bulk_upload to fill the datastore.
>
> Or split it up in parts, each part starting with a different
> character. Put it in db.TextProperty.
>
> 2009/3/16 prasy <prasanna2...@gmail.com>:

Matthew Page-Lieberman

unread,
Mar 16, 2009, 2:21:33 PM3/16/09
to google-a...@googlegroups.com
Also, Prasy, try running this spell check application on your outgoing emails...
--
M. Page-Lieberman
mateus....@gmail.com

jeffkyjin

unread,
Mar 19, 2009, 11:34:52 AM3/19/09
to Google App Engine
Can you show me how to do this?
Thanks!

Matthew Page-Lieberman

unread,
Mar 19, 2009, 1:10:09 PM3/19/09
to google-a...@googlegroups.com
:) I was kidding. You are using Gmail, so it should already be notifying you of misspelled words (by underlining them in red - assuming you are using a browser and sending in rich text/html form).

Good Luck with the app.

Peace Hugs
--
M. Page-Lieberman
mateus....@gmail.com

jeffkyjin

unread,
Mar 20, 2009, 1:48:48 AM3/20/09
to Google App Engine
Ok.
Now I found a method to do it.

instead of reading a static file use os.file.
We can use the urllib.urlopen or urllib2.urlopen to get the static
file, then read it.
url = 'http://xxx.appspot.com/myfile.txt'
raw = urlopen(url).read()

or how to change the url to a local address ? 'localhost' ? it seems
not wok.
anyway, it works!


On Mar 20, 1:10 am, Matthew Page-Lieberman <mateus.just...@gmail.com>
wrote:
> mateus.just...@gmail.com

Wooble

unread,
Mar 20, 2009, 9:06:30 AM3/20/09
to Google App Engine
The way to do it is to not upload them as static files, but as program
files. If you really need to serve them as static to users as well,
include 2 copies in your project. The overhead of using urlopen
instead of opening the file directly is going to be comparatively
enormous.
Reply all
Reply to author
Forward
0 new messages