在加载配置单元表时,跳过csv的第一行 [英] Skip first line of csv while loading in hive table

查看:427
本文介绍了在加载配置单元表时,跳过csv的第一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用以下命令在hive中创建了表格 -

  CREATE TABLE db.test 

fname STRING,
lname STRING,
年龄STRING,
mob BIGINT
)行格式定界字段终止BY'\t'存储AS文本文件;

现在从文件加载表格中的数据,我正在使用以下命令 -

 载入数据local inpath'/home/cluster/TestHive.csv'到表db.test; 

问题是,所有的行都被插入,我不想第一行,因为它包含只有列名称。



请给我一个跳过第一行的方法。

提前致谢。为了得到这个,你可以使用hive的属性,这个属性是 TBLPROPERTIES(skip.header。

line.count=1)

您也可以参考示例 -

  CREATE TABLE temp 

name STRING,
id INT

行格式定界字段终止BY'\t'行终止BY'\\\
'
tblproperties(skip.header.line.count=1);


Hello Friends,

I created table in hive with help of following command -

CREATE TABLE db.test 
  ( 
     fname STRING, 
     lname STRING, 
     age   STRING, 
     mob   BIGINT 
  ) row format delimited fields terminated BY '\t' stored AS textfile; 

Now to load data in table from file, I am using following command -

load data local inpath '/home/cluster/TestHive.csv' into table db.test;

Problem is, all the rows are getting inserted, and I don't want first row because it contains only column names.

Please suggest me a way to skip first line.

Thanks in advance.

解决方案

To get this you can use hive's property which is TBLPROPERTIES ("skip.header.line.count"="1")
you can also refer example -

CREATE TABLE temp 
  ( 
     name STRING, 
     id   INT 
  ) 
row format delimited fields terminated BY '\t' lines terminated BY '\n' 
tblproperties("skip.header.line.count"="1"); 

这篇关于在加载配置单元表时,跳过csv的第一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆