I’m copying information from some text files into a dbf file, which by the way has to be a dbf for work reasons, I’ve been storing data without much problems all things considered and all of a sudden i added a new value, here is a summary of my code without the surrounding code just so things can be understood more easily, and just assume that tipo_2 and tipo_3 are already well defined in previous steps
import dbf
DBF = dbf.Table('inp_rvi.dbf')
DBF.open(mode=dbf.READ_WRITE)
DBF.zap()
recno=0
for row in tipo_2:
persons=int(row[2])
for person in range(0,persons-1):
recno += 1
tupla = {'LLAVE':recno}
#more code lived here and was removed as it
tupla['NOMBRE']=tipo_3[recno-1,3]
i+=1
DBF.append(tupla)
DBF.close()
the problem being that “NOMBRE” is supposed to store names but it throws at me an overflow error saying (‘tried to store 35 bytes in 30 byte field’,) I am rather stuck with this as I’m new to python. By the way the code fails when trying to store the dict “tupla” into “DBF”, I used this variable “tupla” with many other entries and it is “nombres” the one that breaks it
I have tried looking at the source code but I still don’t get why this error occurs, and other than this this is the closest I’ve been to solving this task I have tried using other ways to handle dbfs but all of them break at some point or another when trying to re-store the data back into a dbf, I cannot reduce the size of ‘Nombres’ as it was predefined in a DBF that I must work with. I can try other dbf libraries but I would much rather not have to.
vulpes axis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.