如何从Hadoop数据库将非CSII字符读入jupyterhub

2024-10-01 22:28:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我想从Hadoop数据库中读取除ACSII字符以外的其他字符的数据。我正在尝试使用.py文件读取数据。我用过

#!/usr/bin/env python
# -*- coding: utf-8 -*-

指定编码

我使用下面的查询来提取数据

def hiveconnection(host_name, port, user, database):
    conn = hive.Connection(host=host_name, port=port, username=user, database=database, auth='KERBEROS', kerberos_service_name='impala')
    cur = conn.cursor()
    cur.execute(" select * from db_name.table_name ")
    result = cur.fetchall()
    return result
output = hiveconnection(host_name, port, user, database)
denialt2= pd.DataFrame(output) 

我收到了错误信息。错误消息:“utf-8”编解码器无法解码位置13中的字节0x96:无效的开始字节”。在调查错误消息时,我知道它抛出错误消息是因为ASCII字符以外的特殊字符。从其中一列粘贴下面的特殊字符

enter image description here

附加完整的回溯(错误消息)

enter image description here

请帮我解决这个问题。提前感谢:)


Tags: 数据namehost消息outputport错误result

热门问题