python读取文件数据导入到hbase
2014-03-10 14:45
806 查看
from thrift import Thrift from thrift.transport import TSocket from thrift.transport import TTransport from thrift.protocol import TBinaryProtocol from hbase import Hbase from hbase.ttypes import * import re import sys import time current_row=0 transport = TSocket.TSocket('192.168.106.36', 9090) transport = TTransport.TBufferedTransport(transport) protocol = TBinaryProtocol.TBinaryProtocol(transport) client = Hbase.Client(protocol) transport.open() startTime = time.time() print str(startTime) file1 = open("/data/tmp_data/sqlunload/cmmb/1111.txt", "r") while True: line=file1.readline() if line: line=line.strip('\n') m=re.split("[,]",line) mutations = [Mutation(column = "cf1:finishTime", value =m[1]), Mutation(column = "cf1:requestLine", value =m[2]), Mutation(column = "cf1:returnCode", value = m[3])] client.mutateRow('employees', m[0], mutations, None) current_row = current_row + 1 else : break endTime = time.time() print str(endTime) print "total insert rows:" + str(current_row) print "cost time:" + str(endTime - startTime)
相关文章推荐
- 读取hive文件并将数据导入hbase
- 读取hive文件并将数据导入hbase
- python 文件处理模块的使用,如何读取文件中数据
- python 读取.csv文件数据到数组(矩阵)的实例讲解
- Python导出数据到Excel可读取的CSV文件的方法
- python读取txt文件中的数据
- SQL 数据的导入导出,对远程(MSsql,OracleAccess,)数据库的操作以及读取Excel,txt文件中的数据
- 初识Hbase-使用批量导入将.TSV文件中数据导入到Hbase表中
- [Python]将Excel文件中的数据导入MySQL
- python-从文件读取json数据写到数据库
- python读取文件数据绘直角坐标图
- 利用python做数据分析(五)-读取合并多个文件
- mapreduce读取hbase数据输出到文件中
- python 读取文件第一列 空格隔开的数据
- python使用pandas读取数据文件
- Python读取和处理文件后缀为".sqlite"的数据文件
- python利用thrift服务读取hbase数据
- python读写文件数据(换行写入以及按行读取)
- HBase数据迁移(2)- 使用bulk load 工具从TSV文件中导入数据
- 使用python pandas读取csv文件数据