What data type is col1
? Basic dbf data types are Char
(text), Date
(datetime), Logical
(boolean) Number
(integer/float), Float
(integer/float), and Memo
(unbounded text).
If col1
is not a Char field, comparing to a string will always return False. If col1
is a Char field, then it will compare equal only when col1
is excatly 'true' -- not 'true ' or 'True' or 'TRUE'.
If the problem is extra spaces (by default my module returns the entire field, including trailing spaces) you can either do:
if record.col1.strip() == 'true':
or tell dbf.Table
to use a custom Char
type that ignores trailing spaces:
my_table = dbf.Table('/path/to/file', default_data_types={'C':dbf.Char})