首页 > 解决方案 > 为 NLP 预处理 .txt 文件

问题描述

我有超过一百个非结构化 .txt 文件(文章)需要对 NLP 进行预处理,我必须先将 .txt 文件转换为 .csv 文件吗?或者我可以开始使用原始文本文件进行清理吗?如果是这样,有人可以帮助我使用 Python 进行批处理文件类型转换吗?

标签: python-3.xnlp

解决方案


不,不需要将文本文件转换为 csv。您可以使用 python.docx 轻松读取 word 文件。首先,您需要安装 python.docx。在python 3中:

!pip install python.docx  //install python docx

from  docx import Document  //import docx

doc=open("TextFileName.docx","rb") //creating a word file object

document=docx.Document(doc) //creating word reader object

推荐阅读