Day 28 - Play with MS-Word using Python Script
Sometimes we have to scan the data from MS-Word so that we would proceed with next set of activities. Here you go, buddy !!!! You can use this script to read the content of MS-word + Add a new paragraph in the doc + Add a new image in the doc Python Script: # -*- coding: utf-8 -*- """ Created on Tue Jun 16 18:43:01 2020 @author: Rakesh.Ranjan """ import docx import pandas as pd doc = docx.Document("C:\\Users\\Rakesh.Ranjan\\Desktop\\LND\\MS-DOC.docx") #reading 1st paragraph single_para = doc.paragraphs[0] print(single_para.text) line_number = 0 #Reading all Paragraphs all_paras = doc.paragraphs print(len(all_paras)) #creating an empty dataframe column_names = ["line_number","line_text"] doc_df = pd.DataFrame(columns = column_names) #reading each paragraph and storing it in the dataframe for para in all_paras: doc_df = doc_df.append({"line_number":line_number, "line_tex...