database
Terry Reedy
tjreedy at udel.edu
Thu Jul 15 18:33:10 EDT 1999
In article <3787c551.1 at ganymede.datanet.hu>, granadam at mail.datanet.hu says...
>i am new to python.......
>
>i have a database (comma separated text), and i would like to get some data
>out of it based on some query. let's say there are seven fields, f1...f7,
>and i am searching for entries in f1, and want to display f1..f7 for the
>field that matches the query. how do i go about doing that?
After reading in lines with readline() or readlines(), use
string.splitfields(line,',') to split each line (this assumes that you do not
have ,s embedded within quoted strings -- which is why people sometimes use
something obscure like '|' as a field separator). Then use == comparison or
one of the string search functions to test f1.
Terry J. Reedy
More information about the Python-list
mailing list