Lookup values from one table to another based on a value

Bruno Desthuilliers bruno.42.desthuilliers at wtf.websiteburo.oops.com
Thu Sep 20 11:34:55 EDT 2007


koutoo at hotmail.com a écrit :
> If I wanted to accomplish looking up values from one table based on a
> value from another table or file, how would I go about doing this in
> Python?  Would I build a dictionary or an array?
> 
> exp:
> 
> Table1:
> 
> Site = 103
> Lane = 2
> Dir = ?  # Get this from Table2
> 
> Table2:
> 
> Site, Lane, Direction,
> 103, 1, 1
> 103, 2, 1
> 103, 3, 5
> 103, 4, 5
> 
> Normally in Access I would just use a Dlookup and be done with it, or
> use a Recordset in VB.  Thanks guys.

What about using a database ? Like SQLite ?

Else, the canonical data structure for quick lookups is of course the dict.



More information about the Python-list mailing list