【发布时间】:2018-01-22 10:53:14
【问题描述】:
我正在使用 pandas 从 Excel 工作表中读取数据。我需要使用 pyspark 将数据插入 HIVE。
sparkConf = SparkConf().setAppName("App")
sc = SparkContext(conf = sparkConf)
sqlContext = HiveContext(sc)
excel_file = pd.ExcelFile("export_n_moreExportData10846.xls")
for sheet_name in excel_file.sheet_names:
try:
df = pd.read_excel(excel_file, header=None, squeeze=True, sheet_name=sheet_name)
for i, row in df.iterrows():
if row.notnull().all():
data = df.iloc[(i+1):].reset_index(drop=True)
data.columns = list(df.iloc[i])
break
for c in data.columns:
data[c] = pd.to_numeric(data[c], errors='ignore')
print data #I need to insert this data into HIVE
except:
continue
【问题讨论】:
标签: pandas hive pyspark pyspark-sql