1

The error I encountered while taking data from DynamoDB;

UnicodeEncodeError: 'charmap' codec can't encode character '\u2019' in position 1761: character maps to

Codes;

self.db = boto3.resource(
        'dynamodb',
        region_name=Config.AWS_DB_REGION_NAME,
        aws_access_key_id=Config.AWS_DB_ACCESS_KEY,
        aws_secret_access_key=Config.AWS_DB_SECRET_KEY
)
self.tableName = "test"

queryAll():
    self.actionTable = self.db.Table(self.tableName)

    query = self.actionTable.scan(
        ProjectionExpression='id, cityName, title, lat, lng',
        FilterExpression=Attr("type").eq("attraction")
    )

    return query

venues = queryAll()

print("Found Records: {}\n".format(str(venues['Count']) + "/" + 
str(venues['ScannedCount'])))
founds = list()

if venues['Count']:
 for i, item in enumerate(venues['Items']):
    if "lat" in item:
        founds.append(
            {
                "id": item["id"],
                "title": str(item["title"]),
                "location": str(item['lat']) + "," + str(item['lng'])
            })
print(founds)
Items = venues['Items']
exit()
8
  • please change your title, it's too filthy. can you please provide full error stack please. Commented Jul 16, 2018 at 13:47
  • @Mr.J english is not too good :( Commented Jul 16, 2018 at 13:50
  • now, looks good, please provide me error stack in details. Commented Jul 16, 2018 at 13:51
  • @Mr.J, I can not write the data I added to the founds variable Commented Jul 16, 2018 at 13:59
  • which line from above code is causing error? i need error details not source code or input Commented Jul 16, 2018 at 14:00

1 Answer 1

1

solve the problem with this function

.encode('ascii','ignore').decode()

using;

"title": str(item["title"]).encode('ascii','ignore').decode(),
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.