如何导入nosql数据库 nosql数据库入门?

如何导入nosql数据库 nosql数据库入门


慕工程0101907
浏览 1013回答 1
1回答

尚方宝剑之说

1. 使用python脚本可以轻松生成满足条件的数据,具体如下#coding: utf-8import os, sys, time, datetimefrom itertools import izipN = 100000000def gen_meid(): returndef gen_seq(): returndef generate_message(meid,seq): ts = time.time(); time_st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S') print '/t'.join(( meid, seq, '/N', '/N', '/N', '/N', '0', '0', '0', '0', time_st, '/N', '/N', '0', '/N', '/N', '/N', '/N', time_st ))def main(args): print '/t'.join(( 'deviceID', 'battery', ... , 'accumulatedTime', 'createDate' )) // for mongodb, mysql delete for meid,seq in izip(gen_meid(),gen_seq()): generate_message(meid,seq) pass return 0#==============================if __name__ == "__main__": import sys main(sys.argv) pass#==============================$ python a.py > device.tsv2. 切分数据(可选)tail -n +1 device.csv | head -n 5000000 > part1.txttail -n +100001 device.csv | head -n 100000 > part2.txttail -n +200001 device.csv | head -n 100000 > part3.txttail -n +300001 device.csv | head -n 100000 > part4.txt3. 生成txt 文件python a.py > device.txt
打开App,查看更多内容
随时随地看视频慕课网APP