【发布时间】:2018-01-20 09:51:48
【问题描述】:
我是大数据的学习者,我正在尝试将文件加载到 Hbase 表中。文件内容看起来像 -
U100,A300&A301&A302
U101,A301&A302
U102,A302
U103,A303&A301&A302
此文件存在于本地文件系统中。我想要的是将这些数据加载到 Hbase 表中,如下所示-
我正在尝试下面的脚本,但无法获得这个确切的输出-
echo "create 'uid-map', 'users'" | hbase shell
file="/home/abc/lookupfiles/uid.txt"
touch /home/abc/lookupfiles/uid1.txt
chmod 775 /home/abc/lookupfiles/uid1.txt
file1="/home/abc/lookupfiles/uid1.txt"
awk '$1=$1' FS="&" OFS=" " $file > $file1
num=1
while IFS= read -r line
do
uid=`echo $line | cut -d',' -f1`
users=`echo $line | cut -d'&' -f2`
for row in $users
do
#artist= 'echo $row | cut -d',' -f$num
echo "put 'uid-map', '$uid', 'users:artist$num', '$row'" | hbase shell
let "num=num+1"
done
num=1
done <"$file"
我得到的输出是-
【问题讨论】:
标签: linux shell awk hbase bigdata