如何将csv文件解析为表中的apachehbase?

yfwxisqw  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(337)

我是apachehbase新手,需要将带有值的csv文件解析到hbase中的表中
下面的代码是我尝试过的:

public class HBaseDataInsert
{ 
    Configuration conf; 
    HTable hTable; 
    HBaseScan hbaseScan;

    public HBaseDataInsert() throws IOException
    {
        conf = HBaseConfiguration.create();
        hTable = new HTable(conf, "emp_java");
    }

    public void upload_transactionFile() throws IOException 
    {

        String currentLine = null;
        BufferedReader br = new BufferedReader(
            new FileReader("transactionsFile.csv"));
        while ((currentLine = br.readLine()) != null) 
        {
            System.out.println(currentLine);
            String[] line = currentLine.split(",");
            Put p = new Put(Bytes.toBytes(line[0] + "_" + line[1]));
            p.add(Bytes.toBytes("details"), Bytes.toBytes("Name"), Bytes.toBytes(line[0]));
            p.add(Bytes.toBytes("details"), Bytes.toBytes("id"), Bytes.toBytes(line[1]));
            p.add(Bytes.toBytes("details"), Bytes.toBytes("DATE"), Bytes.toBytes(line[2]));
            p.add(Bytes.toBytes("transaction details"), Bytes.toBytes("TRANSACTION_TYPE"), Bytes.toBytes(line[3]));

            hTable.put(p);
       }
    }
}

我得到以下错误:
/tmp/ java 岛/HBAStainsert。java:24:错误:解析时到达文件结尾}

nnvyjq4y

nnvyjq4y1#

你错过了比赛 "}" 为了你的主课。请在末尾加上并核对。

相关问题