Hive导入CSV数据解决乱码

创建表

hive> create table tbcsv1(id string,name string,age string)
. . > row format serde
. . > 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
. . > with SERDEPROPERTIES
. . > ("separatorChar"=",","quotechar"="\"")

. . > STORED AS TEXTFILE;

导入数据

hive> load data local inpath "e:/hive/tbcsv1.csv" into table tbcsv;


显示数据

hive> select * from tbcsv ;

1,chy,21
2,zjj,25

3,?????,50

发现中文乱码,csv可以使用文本编辑器打开


可以看到使用 vsCode打开在utf-8编码格式下是乱码,利用记事本打开csv另存为时发现编码格式是ANSI,另存为utf-8编码。


删除表重新导入数据



猜你喜欢

转载自blog.csdn.net/chy2z/article/details/80993367