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

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

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

  1. public class HBaseDataInsert
  2. {
  3. Configuration conf;
  4. HTable hTable;
  5. HBaseScan hbaseScan;
  6. public HBaseDataInsert() throws IOException
  7. {
  8. conf = HBaseConfiguration.create();
  9. hTable = new HTable(conf, "emp_java");
  10. }
  11. public void upload_transactionFile() throws IOException
  12. {
  13. String currentLine = null;
  14. BufferedReader br = new BufferedReader(
  15. new FileReader("transactionsFile.csv"));
  16. while ((currentLine = br.readLine()) != null)
  17. {
  18. System.out.println(currentLine);
  19. String[] line = currentLine.split(",");
  20. Put p = new Put(Bytes.toBytes(line[0] + "_" + line[1]));
  21. p.add(Bytes.toBytes("details"), Bytes.toBytes("Name"), Bytes.toBytes(line[0]));
  22. p.add(Bytes.toBytes("details"), Bytes.toBytes("id"), Bytes.toBytes(line[1]));
  23. p.add(Bytes.toBytes("details"), Bytes.toBytes("DATE"), Bytes.toBytes(line[2]));
  24. p.add(Bytes.toBytes("transaction details"), Bytes.toBytes("TRANSACTION_TYPE"), Bytes.toBytes(line[3]));
  25. hTable.put(p);
  26. }
  27. }
  28. }

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

nnvyjq4y

nnvyjq4y1#

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

相关问题