MATLAB 帮助中心
Write documents to text file
writeTextDocument(documents,filename)
writeTextDocument(documents,filename,'Append',true)
writeTextDocument(documents,filename) writes documents to the specified text file. The function writes one document per line with a space between each word in UTF-8.
documents
filename
example
writeTextDocument(documents,filename,'Append',true) appends to the file instead of overwriting.
collapse all
Write an array of documents to a text file.
documents = tokenizedDocument([ "an example of a short sentence" "a second short sentence"])
documents = 2×1 tokenizedDocument: 6 tokens: an example of a short sentence 4 tokens: a second short sentence
filename = "documents.txt"; writeTextDocument(documents,filename)
Write an array of documents to a text file by appending the documents one at a time.
Create an array of tokenized documents.
Write the first document to the file.
filename = "documents.txt"; writeTextDocument(documents(1),filename)
View the contents of the file using extractFileText.
extractFileText
str = extractFileText(filename)
str = "an example of a short sentence"
Append the second document to the text file.
writeTextDocument(documents(2),filename,'Append',true)
str = "an example of a short sentence a second short sentence"
tokenizedDocument
Input documents, specified as a tokenizedDocument array.
Name of the file, specified as a string scalar, character vector, or a 1-by-1 cell array containing a character vector.
Data Types: string | char | cell
string
char
cell
Introduced in R2017b
extractFileText | extractHTMLText | readPDFFormData | tokenizedDocument
extractHTMLText
readPDFFormData
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处