Main Content

writeTextDocument

텍스트 파일에 문서 쓰기

설명

예제

writeTextDocument(documents,filename)은 지정된 텍스트 파일에 documents를 씁니다. 이 함수는 UTF-8 형식으로 각 단어 사이에 공백을 넣어 한 줄에 하나씩 문서를 씁니다.

예제

writeTextDocument(documents,filename,'Append',true)는 덮어쓰는 대신 파일에 추가합니다.

예제

모두 축소

텍스트 파일에 문서로 구성된 배열을 씁니다.

documents = tokenizedDocument([
    "an example of a short sentence" 
    "a second short sentence"])
documents = 
  2x1 tokenizedDocument:

    6 tokens: an example of a short sentence
    4 tokens: a second short sentence

filename = "documents.txt";
writeTextDocument(documents,filename)

한 번에 하나씩 문서를 추가하는 방법으로 문서로 구성된 배열을 텍스트 파일에 씁니다.

토큰화된 문서로 구성된 배열을 만듭니다.

documents = tokenizedDocument([
    "an example of a short sentence" 
    "a second short sentence"])
documents = 
  2x1 tokenizedDocument:

    6 tokens: an example of a short sentence
    4 tokens: a second short sentence

첫 번째 문서를 파일에 씁니다.

filename = "documents.txt";
writeTextDocument(documents(1),filename)

extractFileText를 사용하여 파일의 내용을 표시합니다.

str = extractFileText(filename)
str = 
"an example of a short sentence"

텍스트 파일에 두 번째 문서를 추가합니다.

writeTextDocument(documents(2),filename,'Append',true)

extractFileText를 사용하여 파일의 내용을 표시합니다.

str = extractFileText(filename)
str = 
    "an example of a short sentence
     a second short sentence"

입력 인수

모두 축소

입력 문서로, tokenizedDocument 배열로 지정됩니다.

파일 이름으로, string형 스칼라, 문자형 벡터 또는 문자형 벡터를 포함하는 1×1 셀형 배열로 지정됩니다.

데이터형: string | char | cell

버전 내역

R2017b에 개발됨