2

I need to load data of csv file into hbase table. I have the csv file in the above format

Csv file: Read Detachcard.csv

year  class    days   mm   
   1964   9     20.5     8.8          
   1964  10     13.6     4.2      
   1964  11     11.8     4.7     
   1964  12      7.7     0.1       
   1965   1      7.3     0.8       
   1965   2     6.5     0.1         
   1965   3     10.8     1.4         
   1965   4     13.2     3.5         
   1965   5     16.1     7.0         
   1965   6     19.0     9.2          
   1965   7     18.7    10.7       
   1965   8     19.9    10.9          
   1965   9      16.6     8.2 

In the above file, the top first row is column qualifier names and from 2nd row is the values for column qualifier. now i need to load this data into hbase table using mapreducing program. How to read this data into put command and row autoincrement? I have no idea of this kind of format. please can any one guide me or show me some samples to load this kind of data into hbase table

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Navyah
  • 1,660
  • 10
  • 33
  • 58

2 Answers2

2

Use csvreader , it is quite easy to operate on csv files with this jar. find csvreader jar and place it in jre.

CsvReader products = new CsvReader("CSV file path ");

        products.readHeaders();

        while (products.readRecord())
        {
            String productID = products.get("year");
            String productName = products.get("class");
            String supplierID = products.get("day");
            String categoryID = products.get("mm");

        }

        products.close();
Harika Mamidi
  • 452
  • 4
  • 20
  • 1
    Hi, i need to use MapReduce only which doesnt have CSVREADER, i have updated my post with my class please check – Navyah Sep 12 '12 at 11:12
2

I think your data is 'tab : \t' separated. What you can do is, read/parse each line in your mapper and create a put object then pass it to hbase.

check this link : What is the fastest way to bulk load data into HBase programmatically?

Community
  • 1
  • 1
  • 1
    Please check, i have updated my question. i need to read data from that file , i am not sure how to read data into put method and add data – Navyah Sep 12 '12 at 11:10