如何在hive表中加载csv文件?

问题描述 投票:0回答:1

我在 hive 中创建表并从 hdfs 加载 csv 文件,但是当尝试对创建的表执行选择查询时,我得到加密格式的结果,您能否为此提供解决方案。

create table if not exists studentsinforamtion(
  studentnumber string ,
  universityname  string,
  collegename   string,
  studentname string, 
  branch string, 
  percentage string,
  areaters string,
  rankatuniversity INT,
  eligibleforcompnay string,
  selectedcompanylist int) 
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
stored as textfile;

load data inpath '/user/root/jobportal/studentinfo.ods' overwrite into table studentsinforamtion;

select * from studentsinforamtion limit 5;

错误:

OK
PK5:�C�l9�.mimetypeapplication/vnd.oasis.opendocument.spreadsheetPK5:�C�{C44meta.xml<?xml version="1.0" encoding="UTF-8"?>  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL
<office:document-meta xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:grddl="http://www.w3.org/2
hive
1个回答
0
投票

看起来您的文件不是纯逗号分隔文件(或制表符分隔,正如我从表的分隔符中看到的那样)。它有一些 opendocument 元数据“mimetypeapplication/vnd.oasis.opendocument.spreadsheetPK5:�C�{C44meta.xml”。尝试将文档保存为 .csv 格式或使用简单的文本编辑器创建所需的电子表格。

仅供参考 - 选择结果中的“NULL”通常意味着列类型和值类型不同 - 例如您有一个包含列类型(int、int、int)的表,并且已将包含值(15、23、userinfo)的文件下载到其中 - select 应返回 15、23、NULL。 Hive 在上传过程中不会检查值的类型,因此请注意它们。

© www.soinside.com 2019 - 2024. All rights reserved.