# Author Qian Chenglong
import tensorflow as tf
import numpy as np
file_name='input20181209.txt'
with open(file_name+'_train.txt', 'w') as train_txt:
with open(file_name+'_test.txt', 'w') as test_txt:
# 读取txt文件,每行按制表符分割提取数据
with open(file_name, 'r') as file_txt:
count = len(file_txt.readlines()) #获取文件总的行数
print(count)
file_txt.seek(0) #回到文件开头
for i in range(count):
line_datas = file_txt.readline()
if(i%10==0): #每10个数据1个测试集
test_txt.write(line_datas)
else:
train_txt.write(line_datas)
python自动划分txt文件数据的train_date和test_date
最新推荐文章于 2022-12-07 09:16:48 发布