在这里,您有以下选项:
1)使用hive直接读取Excel文件,并将ctas读取到csv格式的表中。
您需要部署hadoopoffice excel serde
https://github.com/ZuInnoTe/hadoopoffice/wiki/Hive-Serde
然后您需要创建表(参见文档了解所有选项,示例从Sheet1读取并跳过前3行)
create external table ExcelTable() ROW FORMAT SERDE 'org.zuinnote.hadoop.excel.hive.serde.ExcelSerde' STORED AS INPUTFORMAT 'org.zuinnote.hadoop.office.format.mapred.ExcelFileInputFormat' OUTPUTFORMAT 'org.zuinnote.hadoop.excel.hive.outputformat.HiveExcelRowFileOutputFormat' LOCATION '/user/office/files' TBLPROPERTIES("hadoopoffice.read.simple.decimalFormat"="US","hadoopoffice.read.sheet.skiplines.num"="3", "hadoopoffice.read.sheet.skiplines.allsheets"="true", "hadoopoffice.read.sheets"="Sheet1","hadoopoffice.read.locale.bcp47"="US","hadoopoffice.write.locale.bcp47"="US");
然后做
CTAS
到csv格式表中:
create table CSVTable ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' AS Select * from ExcelTable;
2)使用火花
根据Spark版本,您有不同的选择:
对于spark 1.x,可以使用hadoopoffice文件格式,对于spark 2.x,可以使用
Spark2 DataSource
(后者还包括对python的支持)。参见霍尔托斯
here