1.安裝python3
2.使用sublimeText3,配置python(改cmd中的路徑為自己的python)
{
"cmd": ["E:\\python3\\python.exe","-u","$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"encoding":"utf-8"
}
保存的名稱叫Python3.sublime-build默認位置
3.python3安裝pandas和xlrd
打開cmd
pip install xlrd -i https://mirrors.aliyun.com/pypi/simple/
pip install pandas -i https://mirrors.aliyun.com/pypi/simple/
4.編寫代碼
# -*- coding:utf-8 -*-
import pandas as pd
pe=pd.read_excel('C:/Users/rtian/Desktop/a.xls','Sheet1',index_col=0)#可以去掉開頭的,
pe.to_csv('C:/Users/rtian/Desktop/data.csv',encoding='utf-8')
5.hive表,前置建表語句
hive建表的前置語句(我已經建了這個表)
CREATE TABLE
ods.csv_t2
(
name string,
age string
)
row format delimited fields terminated by ','
6.hive導入csv
本地直接上傳
我把csv上傳到/root目錄下了
打開hive
LOAD DATA LOCAL INPATH '/root/data.csv' INTO TABle ods.csv_t2
通過hdfs上傳
在安有hive的機器執行(需要文件在hdfs上)
hdfs dfs -Ddfs.replication=1 -put /root/data.csv /tmp/
打開hive
load data inpath '/tmp/data.csv' into table ods.csv_t2
結果
如果是在hue中執行,需要設定權限。