0
저는이 파일 스플리터를 온라인으로 가져 왔지만 파일 청크를 지정된 폴더에 넣어야합니다. 코드는 다음과 같습니다 파이썬으로 폴더에 파일을 두십시오
#define inputs
file = raw_input('enter file location:')
output = raw_input('enter file output location:')
chunk_size = raw_input('choose output chunk size(in bytes):')
# define the function to split the file into smaller chunks
def splitFile(inputFile,chunkSize):
#read the contents of the file
f = open(inputFile, 'rb')
data = f.read()
f.close()
# get the length of data, ie size of the input file in bytes
bytes = len(data)
#calculate the number of chunks to be created
noOfChunks= bytes/chunkSize
if(bytes%chunkSize):
noOfChunks+=1
#create a info.txt file for writing metadata
f = open('info.txt', 'w')
f.write(inputFile+','+'chunk,'+str(noOfChunks)+','+str(chunkSize))
f.close()
chunkNames = []
for i in range(0, bytes+1, chunkSize):
fn1 = "chunk%s" % i
chunkNames.append(fn1)
f = open(fn1, 'wb')
f.write(data[i:i+ chunkSize])
f.close()
#split file into chunks
splitFile(file,chunk_size)
#move chunks to output
그래서 당신이 볼 수 있는지 메신저로, 나는 그냥 "출력"변수의 디렉토리에 파일 청크가 필요 파일 스플리터 모든 만들었습니다. 누군가 나를 도울 수 있습니까?!?
청크를 쓸 때 출력 폴더에 다시 쓰지 않는 이유는 무엇입니까? – Matthew
문제는 복사 된 코드가 무엇을하는지 이해하지 못하기 때문에 어디서 어떻게 수정해야하는지 알 수 없습니다. –
복사했지만 내 버전을 만들 계획입니다. 주위를 물어 보려고 시도했기 때문에 다른 사람이 나에게 실제 함수를 보여 주었기 때문에 복사 한 이유는 파일 분할기를 작성하는 방법을 설명하는 것이 아니기 때문입니다. 나는 그것이 어떻게 작동하는지 이해하지만 일단 그의 "메타 데이터를 작성하기위한 info.txt 파일 만들기"는 나를 비공개 파일 조작에 너무 익숙하지 않은 메신저로 혼란스럽게 만들었지 만 아직도 배우고있다. – user3537613