File size: 660 Bytes
7d9d14f
dbf7201
7d9d14f
 
 
 
 
 
 
 
 
 
 
dbf7201
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import json
from docx import Document

def open_file(filepath):
    with open(filepath, 'r', encoding='utf-8') as infile:
        return infile.read()

def save_file(filepath, content):
    with open(filepath, 'w', encoding='utf-8') as outfile:
        outfile.write(content)

def append_file(filepath, content):
     with open(filepath, 'w', encoding='utf-8') as outfile:
        outfile.write(content)

def read_word_document(filepath):
    try:
        doc = Document(filepath)
        paragraphs = [p.text for p in doc.paragraphs]
        return paragraphs
    except Exception as e:
        print(f"Error reading the Word document: {e}")
        return []