Go Back   Velocity Reviews > Newsgroups > Python
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Python - Data Coding suggestions

 
Thread Tools Search this Thread
Old 02-27-2009, 12:42 PM   #1
Default Data Coding suggestions


Just learning Python and have a project to create a weekly menu and a
shopping list from the menu. This is something I do manually now, so
I'm automating it.

What I'd like is a list of menu choices, such as:
CODE- Description - Est Cost

'B01 - Pancakes, Sausage,and Eggs - $5.80,
'L01 - Tuna Fish sandwices and chips -$ 4.25 ,
'D01 - Dirty Rice and Garlic Bread' - $5.70.

From the choices, I'll create a weekly menu, print the menu, and then
print list of ingredients ( and sum the commom items)

CODE- Item - Qty. - Unit
B01 - pancake mix - 1 - box
B01 - milk - .3 -gal
B01 - eggs - 10 - each
D01 - dirty rice mix - 1 - box
D01 - milk - .3 - gal.

I would like to expand the ingredient list to include other fields
like 'last purchase date' and 'reorder point'.

I've used an example program and started to code it but just realized
I've been coding ABAP in Python, that is set up a data structure and
use that. What I want is to learn code Python in Python.

Question: How should I set up the data? I'm looking at maybe 70 menu
items and maybe 1000 items for the shopping list. I need to be able
to maintain each item also.

I am using python 2.6 but would like to use 3.0.

Thanks for any suggestions!



steven.oldner
  Reply With Quote
Old 02-27-2009, 01:27 PM   #2
Steve Holden
 
Posts: n/a
Default Re: Data Coding suggestions
steven.oldner wrote:
> Just learning Python and have a project to create a weekly menu and a
> shopping list from the menu. This is something I do manually now, so
> I'm automating it.
>
> What I'd like is a list of menu choices, such as:
> CODE- Description - Est Cost
>
> 'B01 - Pancakes, Sausage,and Eggs - $5.80,
> 'L01 - Tuna Fish sandwices and chips -$ 4.25 ,
> 'D01 - Dirty Rice and Garlic Bread' - $5.70.
>
>>From the choices, I'll create a weekly menu, print the menu, and then

> print list of ingredients ( and sum the commom items)
>
> CODE- Item - Qty. - Unit
> B01 - pancake mix - 1 - box
> B01 - milk - .3 -gal
> B01 - eggs - 10 - each
> D01 - dirty rice mix - 1 - box
> D01 - milk - .3 - gal.
>
> I would like to expand the ingredient list to include other fields
> like 'last purchase date' and 'reorder point'.
>
> I've used an example program and started to code it but just realized
> I've been coding ABAP in Python, that is set up a data structure and
> use that. What I want is to learn code Python in Python.
>
> Question: How should I set up the data? I'm looking at maybe 70 menu
> items and maybe 1000 items for the shopping list. I need to be able
> to maintain each item also.
>
> I am using python 2.6 but would like to use 3.0.
>

Well from the nature of the task it seems evident that the data should
be long-lived, and therefore need to be stored on disk. The natural way
to deal with them in the program would be to have recipes, each of which
was associated with a number of ingredient requirements, each of which
was associated with an ingredient.

That way, you can adjust the prices of your ingredients as the market
varies.

Recent versions of Python come with sqlite, a low-cost but surprisingly
efficient relational database implementation. I'd suggest using that,
with the following tables:

Recipe:
id integer primary key
name string

Ingredient
id integer primary key
name string
unit string [oz, gal, etc.]
cost number [cost per unit]

Requirement
recipe integer [id of recipe]
ingredient integer [id of ingredient]
quantity number [amount required for one serving]

So each recipe will have one row in the recipe table, a number of rows
in the requirement table, each of which points also to the relevant
ingredient.

>From there it's a relatively simple task to work out how much of which

ingredients is required to create N helpings of a specific recipe, and
the cost as well.

It will mean understanding a little more about database than you perhaps
do right now, but that's a useful addition to any programmer's bag of
tricks.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/



Steve Holden
  Reply With Quote
Old 02-27-2009, 08:04 PM   #3
Rick Dooling
 
Posts: n/a
Default Re: Data Coding suggestions
On Feb 27, 6:42*am, "steven.oldner" <steven.old...@gmail.com> wrote:
> Just learning Python and have a project to create a weekly menu and a
> shopping list from the menu. *


> Question: *How should I set up the data? *I'm looking at maybe 70 menu
> items and maybe 1000 items for the shopping list. *I need to be able
> to maintain each item also.
>


I agree with Mr. Holden. It's a perfect exercise for using Python with
sqlite3.

And the nice thing about this documentation is it has plenty of good
examples:

http://docs.python.org/library/sqlite3.html

Good luck,

RD


Rick Dooling
  Reply With Quote
Old 02-28-2009, 04:08 PM   #4
steven.oldner
 
Posts: n/a
Default Re: Data Coding suggestions
On Feb 27, 2:04*pm, Rick Dooling <rpdool...@gmail.com> wrote:
> On Feb 27, 6:42*am, "steven.oldner" <steven.old...@gmail.com> wrote:
>
> > Just learning Python and have a project to create a weekly menu and a
> > shopping list from the menu. *
> > Question: *How should I set up the data? *I'm looking at maybe 70 menu
> > items and maybe 1000 items for the shopping list. *I need to be able
> > to maintain each item also.

>
> I agree with Mr. Holden. It's a perfect exercise for using Python with
> sqlite3.
>
> And the nice thing about this documentation is it has plenty of good
> examples:
>
> http://docs.python.org/library/sqlite3.html
>
> Good luck,
>
> RD


Thanks guys. While shopping today I've thought of a few more columns
for my data so my first item will be building the 3 DB tables and a
way to populate them. Since this was intended to automate what I do
on a weekly basis, I didn't think about adding recipes since I know
what I need for the family, but that's a good touch.

Item 1. Build 3 db tables
Item 2. Build app to populate tables.
Item 3. Build app to read tables and print lists.

Anything else?



steven.oldner
  Reply With Quote
Old 02-28-2009, 07:08 PM   #5
Kurt Smith
 
Posts: n/a
Default Re: Data Coding suggestions
On Sat, Feb 28, 2009 at 10:08 AM, steven.oldner <> wrote:

>
> Thanks guys. *While shopping today I've thought of a few more columns
> for my data so my first item will be building the 3 DB tables and a
> way to populate them. *Since this was intended to automate what I do
> on a weekly basis, I didn't think about adding recipes since I know
> what I need for the family, but that's a good touch.
>
> Item 1. Build 3 db tables
> Item 2. Build app to populate tables.
> Item 3. Build app to read tables and print lists.
>
> Anything else?


You might take a look at the source code for the Gourmet Recipe Manager

http://grecipe-manager.sourceforge.net/

It's written in python, has a persistent database (not sure if using
sqlite3) and you might be able to adapt it to your needs.

We use it for our shopping lists here and it's great.

Kurt


Kurt Smith
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
OT: Blu-Ray Region Coding RL DVD Video 11 12-11-2007 04:04 AM
Need suggestions for motherboard / RAM / etc. bigal Hardware 0 07-26-2006 01:01 PM
Re: Monitor suggestions PLEASE! Tom MacIntyre A+ Certification 2 03-06-2004 12:04 AM
Blockbuster Wants Region Coding To End. Scot Gardner DVD Video 31 12-13-2003 02:45 AM
Re: The purpose of dvd region coding? Shouse DVD Video 1 09-02-2003 05:47 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46