Created
April 1, 2016 02:32
-
-
Save copyleftdev/0b42384220a55c34d0ccd1c5107ec9c1 to your computer and use it in GitHub Desktop.
wikitodocx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from docx import Document | |
import uuid | |
def getDocList(rootFoldr): | |
filelst = [] | |
for(dirpath, _, files) in os.walk(rootFoldr): | |
for filename in files: | |
filepath = os.path.join(dirpath, filename) | |
filelst.append(filepath) | |
return (filelst) | |
def convertToDocx(rootFoldr): | |
flst = getDocList(rootFoldr) | |
xdoc = Document() | |
for each_file in flst: | |
with open(each_file, 'r') as rdcontent: | |
for every_line in rdcontent.readlines(): | |
print every_line | |
print "NEW BREAK" | |
#xdoc.add_paragraph('{}'.format(str(each_line))) | |
#xdoc.save('{}/{}.docx'.format(os.path.dirname(os.path.realpath(each_file)),uuid.uuid4())) | |
convertToDocx('data/') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment