本文介绍了插入Hive表中的值并用双引号将csv文件中的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将一个csv文件导出到配置单元表中.关于csv文件:列值包含在双引号中,并用逗号分隔.

I am exporting a csv file into hive table.about the csv file : column values are enclosed within double-quotes , seperated by comma .

来自csv的采样记录

"4","good"
"3","not bad"
"1","very worst"

我用以下语句创建了一个配置单元表,

I created a hive table with the following statement,

创建外部表咖喱(review_rating字符串,review_comment字符串)行格式字段,并以','分隔;

create external table currys(review_rating string,review_comment string ) row format fields delimited by ',';

表已创建.

现在我使用命令load data local inpath加载了数据,并且操作成功.当我查询表格时,

now I loaded the data using the command load data local inpath and it was successful.when I query the table,

select * from currys;

结果是:

"4"  "good"
"3"  "not bad"
"1"   "very worst"

代替

4  good
3  not bad
1  very worst

记录中应插入双引号,而不应该插入双引号.

records are inserted with double-quotes which shouldnt be.

请让我知道如何消除此双引号..非常感谢任何帮助或指导...

Please let me know how to get rid of this double quote .. any help or guidance is highly appreciated...

预先感谢!

推荐答案

您是否使用任何serde?如果是这样,则可以在SERDE PROPERTIES中编写regex命令以删除引号.

Are you using any serde? If so, then you can write a regex command in the SERDE PROPERTIES to remove the quotes.

或者您可以在此处中使用csv-serde并定义quote character.

Or you can use the csv-serde from here and define the quote character.

这篇关于插入Hive表中的值并用双引号将csv文件中的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 01:18