I am trying to create a program that modify different dbf file but since each file have different field name, I am unsure if the python dbf library have the option to specify the field with string.
To modify the data without variable
dbf.write(record, CUSTOM2="Hello")
But when I tried this, it gives an error
dbf.write(record, {'CUSTOM2': "Hello"})
TypeError: write() takes 1 positional argument but 2 were given
There are a couple ways to update records in dbf files:
target_field = 'custom2'
with record:
record[target_field] = "Hello"
write
function with keywords: target_field = 'custom2'
update = {target_field: "Hello"}
dbf.write(record, **update)