How to read tables in multiple docx files in a same folder by python

早过忘川 提交于 2019-12-06 16:10:00

You can use glob to find all your files, e.g:

import glob
for name in glob.glob('Test_Plan/*.docx'):
    doc = Document(name)
    ...

glob will return a list of file names that match the given pattern. You can loop through that list, as shown above by the for loop and open every file in turn. After opening the files you can just plug in your code. Of course, you will have to initialize your variables before the loop.

For splitting the file names I would suggest to use the following approach:

import os.path

path, filename = os.path.split(input)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!