Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Values inserted in hive table with double quotes for string from csv file

Tags:

sql

csv

hadoop

hive

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

Sample record from csv

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

I created a hive table with the following statement,

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

Table created .

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

select * from currys;

The result is :

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

instead of

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...

Thanks beforehand!

like image 579
prasannads Avatar asked Dec 17 '25 11:12

prasannads


1 Answers

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

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

like image 67
visakh Avatar answered Dec 19 '25 06:12

visakh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!