On Wednesday, December 28, 2016 at 8:20:26 AM UTC-8, Sif Baksh wrote:
>
> I’m trying to use web2py to create a program for some of my buddies, it’s
> called “Home Run Derby”. Each member will pick 6 baseball players, only the
> top 5 score will count as a total score for each member.
>
>
>
> Now I get the players name, team and HR by scraping a website and put it
> in a CSV file.
>
>
>
> This works as a standalone script but want to move it to Web2py.
>
>
>
> Here are the features I need help with getting started:
>
> - Put CSV file into DB
>
> - Create a member login
>
> o Associate players with each member
>
>
>
> What I have so far for the DB is:
>
> player_name,team,hr
>
> David Ortiz,Red Sox,38
>
>
>
> Not sure where to start so anything you can do to point me in the correct
> direction I will appreciate it J
>
>
> Thanks,
>
> Sif
>
If you've already worked through Chapter 3 as a warm-up exercise (and intro
to many things web2py-ish),
then here are some ideas:
2nd table for users, something like:
db.define_table('gamers',
Field('game_name'),
Field('game_user', 'reference auth_user', default=auth.user_id),
Field('pick1', 'reference player'),
Field('pick2', 'reference player'),
Field('pick3', 'reference player'),
Field('pick4', 'reference player'),
Field('pick5', 'reference player'))
Note that the auth_user reference gives you access to the email. Decorate
your functions with
@auth.requires_login()
(This is from the Chapter 3 wiki example; the image blog also uses auth)
For importing your csv file,
see
<URL:http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#CSV--one-Table-at-a-time->
db.players.import_from_csv_file(open('test.csv', 'r'))
Hope this helps you get started.
Dave
/dps
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.