import pandas as pd from docx import Document from regex import A,B ,D, E , F def…
- User
import pandas as pd from docx import Document from regex import A,B ,D, E , F
def populate_chambers(excel_path, doc_path, output_path): try: print("Loading Excel data...") df = pd.read_excel(excel_path) print(f"Excel data loaded: {len(df)} rows")
print("Loading Word document...") print("Available columns:", df.columns.tolist()) doc = Document(doc_path) tables = doc.tables print(f"Total tables found in document: {len(tables)}") print(f"formatting") if not tables: print("error") if not tables: print("Error: No tables found in document.") return # Placeholder values for testing # Populate Publishable Matters for i, row in df.iterrows(): if i < len(tables): table = tables[i] # Assume publishable tables appear first if len(table.rows) >= 18: try: table.cell(2, 0).text = f"{A}" # Client Name table.cell(4, 0).text = f"{B}" # Description (in 500 words) table.cell(6, 0).text = f"{D}" # Matter/Case Overview table.cell(10, 0).text = f"{F}" # lead partner table.cell(12, 0).text = f"{B}" # team members table.cell(14, 0).text = f"{D}" # other involved firms table.cell(16, 0).text = f"{E}" # Date of complition print(f"Matter {i} populated successfully.") except IndexError as e: print(f"Error: Table {i} has fewer rows than expected. Skipping entry. {e}") else: print(f"Warning: Table {i} has only {len(table.rows)} rows. Expected at least 18.") doc.save(output_path) print("Document updated successfully!") except Exception as e: print(f"Unexpected error: {e}")File paths
excel_path = r"C:\Users\Administrator\Documents\Submissions- Arbitration (version 1).xlsb.xlsx" doc_path = r"C:\Users\Administrator\Desktop\Legal Era Law Firm.docx" output_path = r"C:\Users\Administrator\Desktop\confif.docx"
populate_chambers(excel_path, doc_path, output_path) in this make chnges for filling the form for all the rows of excel like currently it is filling a singl form for regex A , B , D , E etc as its feils but u have to take data from xecl having the fields commented afetr each cell of the table that this will go to this and store all rows in tem and then in rsults dispaly combined file of all
- Assistant
- User
filling only one row in config.doc
- Assistant
- User
- Assistant
- User
Loading Excel data... Excel data loaded: 23 rows Loading Word document... Template document loaded. Matter 1 populated successfully. Unexpected error: list index out of range PS C:\Users\Administrator\Desktop\Bd team>
- Assistant
- User
import pandas as pd from docx import Document
- Assistant
- User
Warning: Table 11 has only 12 rows. Expected at least 18. Matter 12 populated successfully. Matter 13 populated successfully. Matter 14 populated successfully. Matter 15 populated successfully. Unexpected error: format number 2 of "Ongoing, Reserved for award" is not recognized in string case t is not only limited ot ongoing and compltet string can be anyting ...u just have to pick the text from excel that row and place it as it is
- Assistant
- User
C8 Date of completion or current status 2024-01-06 00:00:00
- Assistant