1 回答
TA贡献1788条经验 获得超4个赞
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.tsv
2. 切分数据(可选)
tail -n +1 device.csv | head -n 5000000 > part1.txt
tail -n +100001 device.csv | head -n 100000 > part2.txt
tail -n +200001 device.csv | head -n 100000 > part3.txt
tail -n +300001 device.csv | head -n 100000 > part4.txt
3. 生成txt 文件
python a.py > device.txt
- 1 回答
- 0 关注
- 1062 浏览
添加回答
举报