728x90
https://hdongle.tistory.com/73
import os
import shutil
path = 'D:/Yolo/darknet/build/darknet/x64/model/fuelhole04_combo'
train_txt = os.path.join(path, 'train.txt')
test_txt = os.path.join(path, 'test.txt')
f = open(train_txt)
lines = f.readlines()
f.close()
#os.remove(train_txt)
f_train = open(train_txt, mode='wt', encoding='utf-8')
f_test = open(test_txt, mode='wt', encoding='utf-8')
for i in range(len(lines)):
if i % 10 == 0:
f_test.write(lines[i])
else:
f_train.write(lines[i])
train.txt에 있는 파일 내용을
train.txt 90%, test.txt 10%의 비율로 나누기
728x90
'파이썬' 카테고리의 다른 글
[Pandas 기초] 데이터프레임 합치기(merge, join, concat) (0) | 2022.08.18 |
---|---|
[Pandas 기초]5.Pandas 데이터 파일 입출력 (0) | 2022.08.17 |
[Python] 파일명 설정을 위한 0 채우기 및 문자열 포매팅 (0) | 2022.08.16 |
[파이썬] if문 안에 정규식 문자열 비교 (0) | 2022.08.16 |
파이썬 크롤링, re로 특정 정보 선택하기(간단한 정규표현식) (0) | 2022.08.12 |
댓글