I am developing a python aws lambda function for migrating dbf files into mysql after reading it from s3. Lambda function get triggered after every dbf file upload. Here is my code,
import boto3
import io
from dbfread import DBF
s3 = boto3.client('s3')
obj = s3.get_object(Bucket='XXXXXX', Key='test.dbf')
f = io.BytesIO(obj['Body'].read())
for line in f.readlines():
for r in DBF(line,encoding='utf-8'):
print(r)
but when I am executing the script I'm getting the below error.
File "E:\Projects\dbf_mysql_migration\dbfread\dbf.py", line 108, in __init__
self.filename = ifind(filename)
File "E:\Projects\dbf_mysql_migration\dbfread\ifiles.py", line 55, in ifind
files = iglob(pat)
File "E:\Projects\dbf_mysql_migration\dbfread\ifiles.py", line 44, in iglob
return glob.glob(ipat(pat))
File "E:\Projects\dbf_mysql_migration\dbfread\ifiles.py", line 24, in ipat
if c.isalpha:
AttributeError: 'int' object has no attribute 'isalpha'
Can you please help me? Is there any better way to read dbf files as streams from s3 .
I had the same issue, and I solved following the next steps: