我是Apache Hbase的新手,我需要使用HBase中的表来解析带有值的csv文件
以下代码就是我尝试过的:
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_D5BSep/HBaseDataInsert.java:24:错误:到达文件末尾 解析}
答案 0 :(得分:0)
您错过了主要课程的"}"
。请在最后添加并检查。