-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvertOffice.py
More file actions
44 lines (34 loc) · 1.19 KB
/
convertOffice.py
File metadata and controls
44 lines (34 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- coding: utf-8 -*-
#
# Convert list of Office files (.docx, .xslx, .pptx) files from
# old text encoding to Unicode.
# A converter object is provided.
import os
import re
import sys
import convertDoc
import convertDoc2
#import convertXLS
#import convertPPT
import convertUtil
def convertOffice(input_path, output_dir, converter, version=2):
print('***** input_path = %s' % input_path)
if input_path.find('unicode.') > 0:
print('This file has UNICODE in the name. Not converted!')
return
extension = os.path.splitext(input_path)[-1]
if extension == '.docx':
if version == 1:
docxProcessor = convertDoc.convertDocx(input_path, output_dir, converter)
docxProcessor.processDocx()
else:
docxProcessor = convertDoc2.convertDocx(input_path, output_dir, converter)
docxProcessor.processDocx()
# elif extension == '.pptx':
# convertPPT.processOnePresentation(input_path, output_dir,
# converter)
# elif extension == '.xlsx':
# convertXLS.processOneSpreadsheet(input_path, output_dir,
# converter)
else:
print('!!! Not processing file type %s: %s !' % (extension, input_path))