-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsample.py
More file actions
27 lines (26 loc) · 848 Bytes
/
Copy pathsample.py
File metadata and controls
27 lines (26 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- coding:utf-8 -*-
import constants
# 采样
def sample():
file_read = open(constants.dir_path + "training.txt")
file_train = open(constants.dir_path + "sample\\training.part", 'w')
file_valid = open(constants.dir_path + "sample\\validation.part", 'w')
file_test = open(constants.dir_path + "sample\\test.part", 'w')
i = 0
for line in file_read:
# file_train.write(line)
if i % 100000 == 0 :
print i
if i < 1800000:
file_train.write(line)
elif i >= 1800000 and i < 2000000:
file_valid.write(line)
else:
file_test.write(line)
if i > 2200000 : # 多了一行数据
file_read.close()
file_train.close()
file_valid.close()
file_test.close()
break
i = i + 1