ΠΈΡΠΏΡΠ°Π²ΠΈΡΡ ΠΊΠΎΠ΄. ΠΠΎΡΠ°Π±ΠΎΡΠΊΠ° ΡΡΡΠ΅ΡΡΠ²ΡΡΡΠ΅Π³ΠΎ ΠΏΡΠΎΠ΄ΡΠΊΡΠ°. Import pdfplumber import pandas as pd import os def extract_text_from_pdf(file_path): “““Extracts text from a PDF file.“““ with pdfplumber.open(file_path) as pdf: text = ''.join(page.extract_text() for page in pdf.pages) # Extract from all pages return text def text_to_dataframes(text): “““Parses text into dataframes based on sections.“““ sections = text.split(“-----“) # Adjust section delimiter if needed columns_history = ['Column1', 'Column2', 'Column3'] # Adjust column names if needed columns_analysis = ['ColumnA', 'ColumnB', 'ColumnC'] # Adjust column names if needed rows_history = [] rows_analysis = [] for section in sections: lines = section.split(“\n“) if “ΠΡΡΠΎΡΠΈΡ Π±ΠΎΠ»Π΅Π·Π½ΠΈ“ in section: # Adjust section identifier if needed for row in lines: if len(row.split(“,“)) == len(columns_history): rows_history.append(row.split(“,“)) elif “ΠΠ½Π°Π»ΠΈΠ·Ρ“ in section: # Adjust section identifier if needed for row in lines: if len(row.split(“,“)) == len(columns_analysis): rows_analysis.append(row.split(“,“)) df_history = pd.DataFrame(rows_history, columns=columns_history) df_analysis = pd.DataFrame(rows_analysis, columns=columns_analysis) return df_history, df_analysis def save_dataframes(df_history, df_analysis): “““Saves dataframes to Excel files.“““ history_file_path = os.path.join(os.path.dirname(__file__), “history.xlsx“) analysis_file_path = os.path.join(os.path.dirname(__file__), “analysis.xlsx“) df_history.to_excel(history_file_path, index=False) # Save even if empty df_analysis.to_excel(analysis_file_path, index=False) # Save even if empty # Example usage: file_path = “ΡΠ°ΠΉΠ».pdf“ text = extract_text_from_pdf(file_path) print(text) # Add this line to print the extracted text df_history, df_analysis = text_to_dataframes(text) save_dataframes(df_history, df_analysis) Π΅ΡΡΡ ΠΊΠΎΠ΄, ΠΎΠ½ ΡΠ°Π±ΠΎΡΠ°Π΅Ρ ΠΈ Π²ΡΠ²ΠΎΠ΄ΠΈΡ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ ΠΎ ΡΠ°ΠΉΠ»Π΅, Π½ΠΎ ΡΠΎΠ·Π΄Π°Π΅Ρ ΠΏΡΡΡΡΠ΅ exel, Π½ΡΠΆΠ½ΠΎ ΠΈΡΠΏΡΠ°Π²ΠΈΡΡ ΡΡΠΎ Π² ΠΊΠΎΠ΄Π΅. Π² ΡΠ°ΠΉΠ»Π΅ ΠΏΡΠΈΠΌΠ΅Ρ ΠΊΠ°ΠΊΠ°Ρ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ Π΄ΠΎΠ»ΠΆΠ½Π° Π±ΡΡΡ.